<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="./js/coder_app.js"></script>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="./rtwreport_utils.js"></script>
<script type="text/javascript" src="./rtwannotate.js"></script>
<link rel="stylesheet" type="text/css" href="./css/coder_app.css"/>
</head>
<body onload="srcFileOnload();">
<pre id="code">
<table class="code" id="codeTbl">
<tr name="1" id="1">
<td><a id="l1" class='ln'>1</a></td><td><span class="ct">/*</span></td></tr>
<tr name="2" id="2">
<td><a id="l2" class='ln'>2</a></td><td><span class="ct"> * Academic License - for use in teaching, academic research, and meeting</span></td></tr>
<tr name="3" id="3">
<td><a id="l3" class='ln'>3</a></td><td><span class="ct"> * course requirements at degree granting institutions only.  Not for</span></td></tr>
<tr name="4" id="4">
<td><a id="l4" class='ln'>4</a></td><td><span class="ct"> * government, commercial, or other organizational use.</span></td></tr>
<tr name="5" id="5">
<td><a id="l5" class='ln'>5</a></td><td><span class="ct"> *</span></td></tr>
<tr name="6" id="6">
<td><a id="l6" class='ln'>6</a></td><td><span class="ct"> * File: tank.c</span></td></tr>
<tr name="7" id="7">
<td><a id="l7" class='ln'>7</a></td><td><span class="ct"> *</span></td></tr>
<tr name="8" id="8">
<td><a id="l8" class='ln'>8</a></td><td><span class="ct"> * Code generated for Simulink model 'tank'.</span></td></tr>
<tr name="9" id="9">
<td><a id="l9" class='ln'>9</a></td><td><span class="ct"> *</span></td></tr>
<tr name="10" id="10">
<td><a id="l10" class='ln'>10</a></td><td><span class="ct"> * Model version                  : 1.67</span></td></tr>
<tr name="11" id="11">
<td><a id="l11" class='ln'>11</a></td><td><span class="ct"> * Simulink Coder version         : 8.13 (R2017b) 24-Jul-2017</span></td></tr>
<tr name="12" id="12">
<td><a id="l12" class='ln'>12</a></td><td><span class="ct"> * C/C++ source code generated on : Thu May 24 15:31:56 2018</span></td></tr>
<tr name="13" id="13">
<td><a id="l13" class='ln'>13</a></td><td><span class="ct"> *</span></td></tr>
<tr name="14" id="14">
<td><a id="l14" class='ln'>14</a></td><td><span class="ct"> * Target selection: ert_shrlib.tlc</span></td></tr>
<tr name="15" id="15">
<td><a id="l15" class='ln'>15</a></td><td><span class="ct"> * Embedded hardware selection: 32-bit Generic</span></td></tr>
<tr name="16" id="16">
<td><a id="l16" class='ln'>16</a></td><td><span class="ct"> * Emulation hardware selection:</span></td></tr>
<tr name="17" id="17">
<td><a id="l17" class='ln'>17</a></td><td><span class="ct"> *    Differs from embedded hardware (MATLAB Host)</span></td></tr>
<tr name="18" id="18">
<td><a id="l18" class='ln'>18</a></td><td><span class="ct"> * Code generation objectives: Unspecified</span></td></tr>
<tr name="19" id="19">
<td><a id="l19" class='ln'>19</a></td><td><span class="ct"> * Validation result: Not run</span></td></tr>
<tr name="20" id="20">
<td><a id="l20" class='ln'>20</a></td><td><span class="ct"> */</span></td></tr>
<tr name="21" id="21">
<td><a id="l21" class='ln'>21</a></td><td></td></tr>
<tr name="22" id="22">
<td><a id="l22" class='ln'>22</a></td><td><span class="pp">#include "tank.h"</span></td></tr>
<tr name="23" id="23">
<td><a id="l23" class='ln'>23</a></td><td><span class="pp">#include "tank_private.h"</span></td></tr>
<tr name="24" id="24">
<td><a id="l24" class='ln'>24</a></td><td></td></tr>
<tr name="25" id="25">
<td><a id="l25" class='ln'>25</a></td><td><span class="ct">/* Exported block parameters */</span></td></tr>
<tr name="26" id="26">
<td><a id="l26" class='ln'>26</a></td><td><a id="26c1" class="tk">real_T</a> <a id="26c8" class="tk">Timedelay</a> = 0.0;                <span class="ct">/* Variable: Timedelay</span></td></tr>
<tr name="27" id="27">
<td><a id="l27" class='ln'>27</a></td><td><span class="ct">                                        * Referenced by: '<a class="ct blk" blk_line="27">&lt;Root&gt;/Transport Delay</a>'</span></td></tr>
<tr name="28" id="28">
<td><a id="l28" class='ln'>28</a></td><td><span class="ct">                                        */</span></td></tr>
<tr name="29" id="29">
<td><a id="l29" class='ln'>29</a></td><td><a id="29c1" class="tk">real_T</a> <a id="29c8" class="tk">buttomarea</a> = 1.0;               <span class="ct">/* Variable: buttomarea</span></td></tr>
<tr name="30" id="30">
<td><a id="l30" class='ln'>30</a></td><td><span class="ct">                                        * Referenced by:</span></td></tr>
<tr name="31" id="31">
<td><a id="l31" class='ln'>31</a></td><td><span class="ct">                                        *   '<a class="ct blk" blk_line="31">&lt;S2&gt;/1//area</a>'</span></td></tr>
<tr name="32" id="32">
<td><a id="l32" class='ln'>32</a></td><td><span class="ct">                                        *   '<a class="ct blk" blk_line="32">&lt;S4&gt;/Integrator</a>'</span></td></tr>
<tr name="33" id="33">
<td><a id="l33" class='ln'>33</a></td><td><span class="ct">                                        *   '<a class="ct blk" blk_line="33">&lt;S4&gt;/Saturation</a>'</span></td></tr>
<tr name="34" id="34">
<td><a id="l34" class='ln'>34</a></td><td><span class="ct">                                        */</span></td></tr>
<tr name="35" id="35">
<td><a id="l35" class='ln'>35</a></td><td><a id="35c1" class="tk">real_T</a> <a id="35c8" class="tk">heightoftank</a> = 2.0;             <span class="ct">/* Variable: heightoftank</span></td></tr>
<tr name="36" id="36">
<td><a id="l36" class='ln'>36</a></td><td><span class="ct">                                        * Referenced by: '<a class="ct blk" blk_line="36">&lt;S4&gt;/Saturation</a>'</span></td></tr>
<tr name="37" id="37">
<td><a id="l37" class='ln'>37</a></td><td><span class="ct">                                        */</span></td></tr>
<tr name="38" id="38">
<td><a id="l38" class='ln'>38</a></td><td><a id="38c1" class="tk">real_T</a> <a id="38c8" class="tk">maxinflow</a> = 0.5;                <span class="ct">/* Variable: maxinflow</span></td></tr>
<tr name="39" id="39">
<td><a id="l39" class='ln'>39</a></td><td><span class="ct">                                        * Referenced by: '<a class="ct blk" blk_line="39">&lt;Root&gt;/tank max inflow1 最大流量</a>'</span></td></tr>
<tr name="40" id="40">
<td><a id="l40" class='ln'>40</a></td><td><span class="ct">                                        */</span></td></tr>
<tr name="41" id="41">
<td><a id="l41" class='ln'>41</a></td><td><a id="41c1" class="tk">real_T</a> <a id="41c8" class="tk">outpipcrosssection</a> = 0.05;      <span class="ct">/* Variable: outpipcrosssection</span></td></tr>
<tr name="42" id="42">
<td><a id="l42" class='ln'>42</a></td><td><span class="ct">                                        * Referenced by: '<a class="ct blk" blk_line="42">&lt;S2&gt;/outletArea</a>'</span></td></tr>
<tr name="43" id="43">
<td><a id="l43" class='ln'>43</a></td><td><span class="ct">                                        */</span></td></tr>
<tr name="44" id="44">
<td><a id="l44" class='ln'>44</a></td><td></td></tr>
<tr name="45" id="45">
<td><a id="l45" class='ln'>45</a></td><td><span class="ct">/* Block signals (auto storage) */</span></td></tr>
<tr name="46" id="46">
<td><a id="l46" class='ln'>46</a></td><td><a id="46c1" class="tk">B_tank_T</a> <a id="46c10" class="tk">tank_B</a>;</td></tr>
<tr name="47" id="47">
<td><a id="l47" class='ln'>47</a></td><td></td></tr>
<tr name="48" id="48">
<td><a id="l48" class='ln'>48</a></td><td><span class="ct">/* Continuous states */</span></td></tr>
<tr name="49" id="49">
<td><a id="l49" class='ln'>49</a></td><td><a id="49c1" class="tk">X_tank_T</a> <a id="49c10" class="tk">tank_X</a>;</td></tr>
<tr name="50" id="50">
<td><a id="l50" class='ln'>50</a></td><td></td></tr>
<tr name="51" id="51">
<td><a id="l51" class='ln'>51</a></td><td><span class="ct">/* Block states (auto storage) */</span></td></tr>
<tr name="52" id="52">
<td><a id="l52" class='ln'>52</a></td><td><a id="52c1" class="tk">DW_tank_T</a> <a id="52c11" class="tk">tank_DW</a>;</td></tr>
<tr name="53" id="53">
<td><a id="l53" class='ln'>53</a></td><td></td></tr>
<tr name="54" id="54">
<td><a id="l54" class='ln'>54</a></td><td><span class="ct">/* External inputs (root inport signals with auto storage) */</span></td></tr>
<tr name="55" id="55">
<td><a id="l55" class='ln'>55</a></td><td><a id="55c1" class="tk">ExtU_tank_T</a> <a id="55c13" class="tk">tank_U</a>;</td></tr>
<tr name="56" id="56">
<td><a id="l56" class='ln'>56</a></td><td></td></tr>
<tr name="57" id="57">
<td><a id="l57" class='ln'>57</a></td><td><span class="ct">/* External outputs (root outports fed by signals with auto storage) */</span></td></tr>
<tr name="58" id="58">
<td><a id="l58" class='ln'>58</a></td><td><a id="58c1" class="tk">ExtY_tank_T</a> <a id="58c13" class="tk">tank_Y</a>;</td></tr>
<tr name="59" id="59">
<td><a id="l59" class='ln'>59</a></td><td></td></tr>
<tr name="60" id="60">
<td><a id="l60" class='ln'>60</a></td><td><span class="ct">/* Real-time model */</span></td></tr>
<tr name="61" id="61">
<td><a id="l61" class='ln'>61</a></td><td><a id="61c1" class="tk">RT_MODEL_tank_T</a> <a id="61c17" class="tk">tank_M_</a>;</td></tr>
<tr name="62" id="62">
<td><a id="l62" class='ln'>62</a></td><td><a id="62c1" class="tk">RT_MODEL_tank_T</a> <a id="62c17" class="tk">*</a><span class="kw">const</span> <a id="62c24" class="tk">tank_M</a> = <a id="62c33" class="tk">&amp;</a><a id="62c34" class="tk">tank_M_</a>;</td></tr>
<tr name="63" id="63">
<td><a id="l63" class='ln'>63</a></td><td></td></tr>
<tr name="64" id="64">
<td><a id="l64" class='ln'>64</a></td><td><span class="ct">/*</span></td></tr>
<tr name="65" id="65">
<td><a id="l65" class='ln'>65</a></td><td><span class="ct"> * Time delay interpolation routine</span></td></tr>
<tr name="66" id="66">
<td><a id="l66" class='ln'>66</a></td><td><span class="ct"> *</span></td></tr>
<tr name="67" id="67">
<td><a id="l67" class='ln'>67</a></td><td><span class="ct"> * The linear interpolation is performed using the formula:</span></td></tr>
<tr name="68" id="68">
<td><a id="l68" class='ln'>68</a></td><td><span class="ct"> *</span></td></tr>
<tr name="69" id="69">
<td><a id="l69" class='ln'>69</a></td><td><span class="ct"> *          (t2 - tMinusDelay)         (tMinusDelay - t1)</span></td></tr>
<tr name="70" id="70">
<td><a id="l70" class='ln'>70</a></td><td><span class="ct"> * u(t)  =  ----------------- * u1  +  ------------------- * u2</span></td></tr>
<tr name="71" id="71">
<td><a id="l71" class='ln'>71</a></td><td><span class="ct"> *              (t2 - t1)                  (t2 - t1)</span></td></tr>
<tr name="72" id="72">
<td><a id="l72" class='ln'>72</a></td><td><span class="ct"> */</span></td></tr>
<tr name="73" id="73">
<td><a id="l73" class='ln'>73</a></td><td><a id="73c1" class="tk">real_T</a> <a id="73c8" class="tk">rt_TDelayInterpolate</a>(</td></tr>
<tr name="74" id="74">
<td><a id="l74" class='ln'>74</a></td><td>  <a id="74c3" class="tk">real_T</a> <a id="74c10" class="tk">tMinusDelay</a>,                  <span class="ct">/* tMinusDelay = currentSimTime - delay */</span></td></tr>
<tr name="75" id="75">
<td><a id="l75" class='ln'>75</a></td><td>  <a id="75c3" class="tk">real_T</a> <a id="75c10" class="tk">tStart</a>,</td></tr>
<tr name="76" id="76">
<td><a id="l76" class='ln'>76</a></td><td>  <a id="76c3" class="tk">real_T</a> <a id="76c10" class="tk">*</a><a id="76c11" class="tk">tBuf</a>,</td></tr>
<tr name="77" id="77">
<td><a id="l77" class='ln'>77</a></td><td>  <a id="77c3" class="tk">real_T</a> <a id="77c10" class="tk">*</a><a id="77c11" class="tk">uBuf</a>,</td></tr>
<tr name="78" id="78">
<td><a id="l78" class='ln'>78</a></td><td>  <a id="78c3" class="tk">int_T</a> <a id="78c9" class="tk">bufSz</a>,</td></tr>
<tr name="79" id="79">
<td><a id="l79" class='ln'>79</a></td><td>  <a id="79c3" class="tk">int_T</a> <a id="79c9" class="tk">*</a><a id="79c10" class="tk">lastIdx</a>,</td></tr>
<tr name="80" id="80">
<td><a id="l80" class='ln'>80</a></td><td>  <a id="80c3" class="tk">int_T</a> <a id="80c9" class="tk">oldestIdx</a>,</td></tr>
<tr name="81" id="81">
<td><a id="l81" class='ln'>81</a></td><td>  <a id="81c3" class="tk">int_T</a> <a id="81c9" class="tk">newIdx</a>,</td></tr>
<tr name="82" id="82">
<td><a id="l82" class='ln'>82</a></td><td>  <a id="82c3" class="tk">real_T</a> <a id="82c10" class="tk">initOutput</a>,</td></tr>
<tr name="83" id="83">
<td><a id="l83" class='ln'>83</a></td><td>  <a id="83c3" class="tk">boolean_T</a> <a id="83c13" class="tk">discrete</a>,</td></tr>
<tr name="84" id="84">
<td><a id="l84" class='ln'>84</a></td><td>  <a id="84c3" class="tk">boolean_T</a> <a id="84c13" class="tk">minorStepAndTAtLastMajorOutput</a>)</td></tr>
<tr name="85" id="85">
<td><a id="l85" class='ln'>85</a></td><td><span class="br">{</span></td></tr>
<tr name="86" id="86">
<td><a id="l86" class='ln'>86</a></td><td>  <a id="86c3" class="tk">int_T</a> <a id="86c9" class="tk">i</a>;</td></tr>
<tr name="87" id="87">
<td><a id="l87" class='ln'>87</a></td><td>  <a id="87c3" class="tk">real_T</a> <a id="87c10" class="tk">yout</a>, <a id="87c16" class="tk">t1</a>, <a id="87c20" class="tk">t2</a>, <a id="87c24" class="tk">u1</a>, <a id="87c28" class="tk">u2</a>;</td></tr>
<tr name="88" id="88">
<td><a id="l88" class='ln'>88</a></td><td></td></tr>
<tr name="89" id="89">
<td><a id="l89" class='ln'>89</a></td><td>  <span class="ct">/*</span></td></tr>
<tr name="90" id="90">
<td><a id="l90" class='ln'>90</a></td><td><span class="ct">   * If there is only one data point in the buffer, this data point must be</span></td></tr>
<tr name="91" id="91">
<td><a id="l91" class='ln'>91</a></td><td><span class="ct">   * the t= 0 and tMinusDelay &gt; t0, it ask for something unknown. The best</span></td></tr>
<tr name="92" id="92">
<td><a id="l92" class='ln'>92</a></td><td><span class="ct">   * guess if initial output as well</span></td></tr>
<tr name="93" id="93">
<td><a id="l93" class='ln'>93</a></td><td><span class="ct">   */</span></td></tr>
<tr name="94" id="94">
<td><a id="l94" class='ln'>94</a></td><td>  <span class="kw">if</span> ((<a id="94c8" class="tk">newIdx</a> <a id="94c15" class="tk">==</a> 0) <a id="94c21" class="tk">&amp;&amp;</a> (<a id="94c25" class="tk">oldestIdx</a> <a id="94c35" class="tk">==</a>0 ) <a id="94c41" class="tk">&amp;&amp;</a> (<a id="94c45" class="tk">tMinusDelay</a> <a id="94c57" class="tk">&gt;</a> <a id="94c59" class="tk">tStart</a>))</td></tr>
<tr name="95" id="95">
<td><a id="l95" class='ln'>95</a></td><td>    <span class="kw">return</span> <a id="95c12" class="tk">initOutput</a>;</td></tr>
<tr name="96" id="96">
<td><a id="l96" class='ln'>96</a></td><td></td></tr>
<tr name="97" id="97">
<td><a id="l97" class='ln'>97</a></td><td>  <span class="ct">/*</span></td></tr>
<tr name="98" id="98">
<td><a id="l98" class='ln'>98</a></td><td><span class="ct">   * If tMinusDelay is less than zero, should output initial value</span></td></tr>
<tr name="99" id="99">
<td><a id="l99" class='ln'>99</a></td><td><span class="ct">   */</span></td></tr>
<tr name="100" id="100">
<td><a id="l100" class='ln'>100</a></td><td>  <span class="kw">if</span> (<a id="100c7" class="tk">tMinusDelay</a> <a id="100c19" class="tk">&lt;=</a> <a id="100c22" class="tk">tStart</a>)</td></tr>
<tr name="101" id="101">
<td><a id="l101" class='ln'>101</a></td><td>    <span class="kw">return</span> <a id="101c12" class="tk">initOutput</a>;</td></tr>
<tr name="102" id="102">
<td><a id="l102" class='ln'>102</a></td><td></td></tr>
<tr name="103" id="103">
<td><a id="l103" class='ln'>103</a></td><td>  <span class="ct">/* For fixed buffer extrapolation:</span></td></tr>
<tr name="104" id="104">
<td><a id="l104" class='ln'>104</a></td><td><span class="ct">   * if tMinusDelay is small than the time at oldestIdx, if discrete, output</span></td></tr>
<tr name="105" id="105">
<td><a id="l105" class='ln'>105</a></td><td><span class="ct">   * tailptr value,  else use tailptr and tailptr+1 value to extrapolate</span></td></tr>
<tr name="106" id="106">
<td><a id="l106" class='ln'>106</a></td><td><span class="ct">   * It is also for fixed buffer. Note: The same condition can happen for transport delay block where</span></td></tr>
<tr name="107" id="107">
<td><a id="l107" class='ln'>107</a></td><td><span class="ct">   * use tStart and and t[tail] other than using t[tail] and t[tail+1].</span></td></tr>
<tr name="108" id="108">
<td><a id="l108" class='ln'>108</a></td><td><span class="ct">   * See below</span></td></tr>
<tr name="109" id="109">
<td><a id="l109" class='ln'>109</a></td><td><span class="ct">   */</span></td></tr>
<tr name="110" id="110">
<td><a id="l110" class='ln'>110</a></td><td>  <span class="kw">if</span> ((<a id="110c8" class="tk">tMinusDelay</a> <a id="110c20" class="tk">&lt;=</a> <a id="110c23" class="tk">tBuf</a>[<a id="110c28" class="tk">oldestIdx</a>] ) ) <span class="br">{</span></td></tr>
<tr name="111" id="111">
<td><a id="l111" class='ln'>111</a></td><td>    <span class="kw">if</span> (<a id="111c9" class="tk">discrete</a>) <span class="br">{</span></td></tr>
<tr name="112" id="112">
<td><a id="l112" class='ln'>112</a></td><td>      <span class="kw">return</span>(<a id="112c14" class="tk">uBuf</a>[<a id="112c19" class="tk">oldestIdx</a>]);</td></tr>
<tr name="113" id="113">
<td><a id="l113" class='ln'>113</a></td><td>    <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="114" id="114">
<td><a id="l114" class='ln'>114</a></td><td>      <a id="114c7" class="tk">int_T</a> <a id="114c13" class="tk">tempIdx</a>= <a id="114c22" class="tk">oldestIdx</a> <a id="114c32" class="tk">+</a> 1;</td></tr>
<tr name="115" id="115">
<td><a id="l115" class='ln'>115</a></td><td>      <span class="kw">if</span> (<a id="115c11" class="tk">oldestIdx</a> <a id="115c21" class="tk">==</a> <a id="115c24" class="tk">bufSz</a><a id="115c29" class="tk">-</a>1)</td></tr>
<tr name="116" id="116">
<td><a id="l116" class='ln'>116</a></td><td>        <a id="116c9" class="tk">tempIdx</a> = 0;</td></tr>
<tr name="117" id="117">
<td><a id="l117" class='ln'>117</a></td><td>      <a id="117c7" class="tk">t1</a>= <a id="117c11" class="tk">tBuf</a>[<a id="117c16" class="tk">oldestIdx</a>];</td></tr>
<tr name="118" id="118">
<td><a id="l118" class='ln'>118</a></td><td>      <a id="118c7" class="tk">t2</a>= <a id="118c11" class="tk">tBuf</a>[<a id="118c16" class="tk">tempIdx</a>];</td></tr>
<tr name="119" id="119">
<td><a id="l119" class='ln'>119</a></td><td>      <a id="119c7" class="tk">u1</a>= <a id="119c11" class="tk">uBuf</a>[<a id="119c16" class="tk">oldestIdx</a>];</td></tr>
<tr name="120" id="120">
<td><a id="l120" class='ln'>120</a></td><td>      <a id="120c7" class="tk">u2</a>= <a id="120c11" class="tk">uBuf</a>[<a id="120c16" class="tk">tempIdx</a>];</td></tr>
<tr name="121" id="121">
<td><a id="l121" class='ln'>121</a></td><td>      <span class="kw">if</span> (<a id="121c11" class="tk">t2</a> <a id="121c14" class="tk">==</a> <a id="121c17" class="tk">t1</a>) <span class="br">{</span></td></tr>
<tr name="122" id="122">
<td><a id="l122" class='ln'>122</a></td><td>        <span class="kw">if</span> (<a id="122c13" class="tk">tMinusDelay</a> <a id="122c25" class="tk">&gt;=</a> <a id="122c28" class="tk">t2</a>) <span class="br">{</span></td></tr>
<tr name="123" id="123">
<td><a id="l123" class='ln'>123</a></td><td>          <a id="123c11" class="tk">yout</a> = <a id="123c18" class="tk">u2</a>;</td></tr>
<tr name="124" id="124">
<td><a id="l124" class='ln'>124</a></td><td>        <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="125" id="125">
<td><a id="l125" class='ln'>125</a></td><td>          <a id="125c11" class="tk">yout</a> = <a id="125c18" class="tk">u1</a>;</td></tr>
<tr name="126" id="126">
<td><a id="l126" class='ln'>126</a></td><td>        <span class="br">}</span></td></tr>
<tr name="127" id="127">
<td><a id="l127" class='ln'>127</a></td><td>      <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="128" id="128">
<td><a id="l128" class='ln'>128</a></td><td>        <a id="128c9" class="tk">real_T</a> <a id="128c16" class="tk">f1</a> = (<a id="128c22" class="tk">t2</a><a id="128c24" class="tk">-</a><a id="128c25" class="tk">tMinusDelay</a>) <a id="128c38" class="tk">/</a> (<a id="128c41" class="tk">t2</a><a id="128c43" class="tk">-</a><a id="128c44" class="tk">t1</a>);</td></tr>
<tr name="129" id="129">
<td><a id="l129" class='ln'>129</a></td><td>        <a id="129c9" class="tk">real_T</a> <a id="129c16" class="tk">f2</a> = 1.0 <a id="129c25" class="tk">-</a> <a id="129c27" class="tk">f1</a>;</td></tr>
<tr name="130" id="130">
<td><a id="l130" class='ln'>130</a></td><td></td></tr>
<tr name="131" id="131">
<td><a id="l131" class='ln'>131</a></td><td>        <span class="ct">/*</span></td></tr>
<tr name="132" id="132">
<td><a id="l132" class='ln'>132</a></td><td><span class="ct">         * Use Lagrange's interpolation formula.  Exact outputs at t1, t2.</span></td></tr>
<tr name="133" id="133">
<td><a id="l133" class='ln'>133</a></td><td><span class="ct">         */</span></td></tr>
<tr name="134" id="134">
<td><a id="l134" class='ln'>134</a></td><td>        <a id="134c9" class="tk">yout</a> = <a id="134c16" class="tk">f1</a><a id="134c18" class="tk">*</a><a id="134c19" class="tk">u1</a> <a id="134c22" class="tk">+</a> <a id="134c24" class="tk">f2</a><a id="134c26" class="tk">*</a><a id="134c27" class="tk">u2</a>;</td></tr>
<tr name="135" id="135">
<td><a id="l135" class='ln'>135</a></td><td>      <span class="br">}</span></td></tr>
<tr name="136" id="136">
<td><a id="l136" class='ln'>136</a></td><td></td></tr>
<tr name="137" id="137">
<td><a id="l137" class='ln'>137</a></td><td>      <span class="kw">return</span> <a id="137c14" class="tk">yout</a>;</td></tr>
<tr name="138" id="138">
<td><a id="l138" class='ln'>138</a></td><td>    <span class="br">}</span></td></tr>
<tr name="139" id="139">
<td><a id="l139" class='ln'>139</a></td><td>  <span class="br">}</span></td></tr>
<tr name="140" id="140">
<td><a id="l140" class='ln'>140</a></td><td></td></tr>
<tr name="141" id="141">
<td><a id="l141" class='ln'>141</a></td><td>  <span class="ct">/*</span></td></tr>
<tr name="142" id="142">
<td><a id="l142" class='ln'>142</a></td><td><span class="ct">   * When block does not have direct feedthrough, we use the table of</span></td></tr>
<tr name="143" id="143">
<td><a id="l143" class='ln'>143</a></td><td><span class="ct">   * values to extrapolate off the end of the table for delays that are less</span></td></tr>
<tr name="144" id="144">
<td><a id="l144" class='ln'>144</a></td><td><span class="ct">   * than 0 (less then step size).  This is not completely accurate.  The</span></td></tr>
<tr name="145" id="145">
<td><a id="l145" class='ln'>145</a></td><td><span class="ct">   * chain of events is as follows for a given time t.  Major output - look</span></td></tr>
<tr name="146" id="146">
<td><a id="l146" class='ln'>146</a></td><td><span class="ct">   * in table.  Update - add entry to table.  Now, if we call the output at</span></td></tr>
<tr name="147" id="147">
<td><a id="l147" class='ln'>147</a></td><td><span class="ct">   * time t again, there is a new entry in the table. For very small delays,</span></td></tr>
<tr name="148" id="148">
<td><a id="l148" class='ln'>148</a></td><td><span class="ct">   * this means that we will have a different answer from the previous call</span></td></tr>
<tr name="149" id="149">
<td><a id="l149" class='ln'>149</a></td><td><span class="ct">   * to the output fcn at the same time t.  The following code prevents this</span></td></tr>
<tr name="150" id="150">
<td><a id="l150" class='ln'>150</a></td><td><span class="ct">   * from happening.</span></td></tr>
<tr name="151" id="151">
<td><a id="l151" class='ln'>151</a></td><td><span class="ct">   */</span></td></tr>
<tr name="152" id="152">
<td><a id="l152" class='ln'>152</a></td><td>  <span class="kw">if</span> (<a id="152c7" class="tk">minorStepAndTAtLastMajorOutput</a>) <span class="br">{</span></td></tr>
<tr name="153" id="153">
<td><a id="l153" class='ln'>153</a></td><td>    <span class="ct">/* pretend that the new entry has not been added to table */</span></td></tr>
<tr name="154" id="154">
<td><a id="l154" class='ln'>154</a></td><td>    <span class="kw">if</span> (<a id="154c9" class="tk">newIdx</a> <a id="154c16" class="tk">!=</a> 0) <span class="br">{</span></td></tr>
<tr name="155" id="155">
<td><a id="l155" class='ln'>155</a></td><td>      <span class="kw">if</span> (<a id="155c11" class="tk">*</a><a id="155c12" class="tk">lastIdx</a> <a id="155c20" class="tk">==</a> <a id="155c23" class="tk">newIdx</a>) <span class="br">{</span></td></tr>
<tr name="156" id="156">
<td><a id="l156" class='ln'>156</a></td><td>        (<a id="156c10" class="tk">*</a><a id="156c11" class="tk">lastIdx</a>)<a id="156c19" class="tk">--</a>;</td></tr>
<tr name="157" id="157">
<td><a id="l157" class='ln'>157</a></td><td>      <span class="br">}</span></td></tr>
<tr name="158" id="158">
<td><a id="l158" class='ln'>158</a></td><td></td></tr>
<tr name="159" id="159">
<td><a id="l159" class='ln'>159</a></td><td>      <a id="159c7" class="tk">newIdx</a><a id="159c13" class="tk">--</a>;</td></tr>
<tr name="160" id="160">
<td><a id="l160" class='ln'>160</a></td><td>    <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="161" id="161">
<td><a id="l161" class='ln'>161</a></td><td>      <span class="kw">if</span> (<a id="161c11" class="tk">*</a><a id="161c12" class="tk">lastIdx</a> <a id="161c20" class="tk">==</a> <a id="161c23" class="tk">newIdx</a>) <span class="br">{</span></td></tr>
<tr name="162" id="162">
<td><a id="l162" class='ln'>162</a></td><td>        <a id="162c9" class="tk">*</a><a id="162c10" class="tk">lastIdx</a> = <a id="162c20" class="tk">bufSz</a><a id="162c25" class="tk">-</a>1;</td></tr>
<tr name="163" id="163">
<td><a id="l163" class='ln'>163</a></td><td>      <span class="br">}</span></td></tr>
<tr name="164" id="164">
<td><a id="l164" class='ln'>164</a></td><td></td></tr>
<tr name="165" id="165">
<td><a id="l165" class='ln'>165</a></td><td>      <a id="165c7" class="tk">newIdx</a> = <a id="165c16" class="tk">bufSz</a> <a id="165c22" class="tk">-</a> 1;</td></tr>
<tr name="166" id="166">
<td><a id="l166" class='ln'>166</a></td><td>    <span class="br">}</span></td></tr>
<tr name="167" id="167">
<td><a id="l167" class='ln'>167</a></td><td>  <span class="br">}</span></td></tr>
<tr name="168" id="168">
<td><a id="l168" class='ln'>168</a></td><td></td></tr>
<tr name="169" id="169">
<td><a id="l169" class='ln'>169</a></td><td>  <a id="169c3" class="tk">i</a> = <a id="169c7" class="tk">*</a><a id="169c8" class="tk">lastIdx</a>;</td></tr>
<tr name="170" id="170">
<td><a id="l170" class='ln'>170</a></td><td>  <span class="kw">if</span> (<a id="170c7" class="tk">tBuf</a>[<a id="170c12" class="tk">i</a>] <a id="170c15" class="tk">&lt;</a> <a id="170c17" class="tk">tMinusDelay</a>) <span class="br">{</span></td></tr>
<tr name="171" id="171">
<td><a id="l171" class='ln'>171</a></td><td>    <span class="ct">/* Look forward starting at last index */</span></td></tr>
<tr name="172" id="172">
<td><a id="l172" class='ln'>172</a></td><td>    <span class="kw">while</span> (<a id="172c12" class="tk">tBuf</a>[<a id="172c17" class="tk">i</a>] <a id="172c20" class="tk">&lt;</a> <a id="172c22" class="tk">tMinusDelay</a>) <span class="br">{</span></td></tr>
<tr name="173" id="173">
<td><a id="l173" class='ln'>173</a></td><td>      <span class="ct">/* May occur if the delay is less than step-size - extrapolate */</span></td></tr>
<tr name="174" id="174">
<td><a id="l174" class='ln'>174</a></td><td>      <span class="kw">if</span> (<a id="174c11" class="tk">i</a> <a id="174c13" class="tk">==</a> <a id="174c16" class="tk">newIdx</a>)</td></tr>
<tr name="175" id="175">
<td><a id="l175" class='ln'>175</a></td><td>        <span class="kw">break</span>;</td></tr>
<tr name="176" id="176">
<td><a id="l176" class='ln'>176</a></td><td>      <a id="176c7" class="tk">i</a> = ( <a id="176c13" class="tk">i</a> <a id="176c15" class="tk">&lt;</a> (<a id="176c18" class="tk">bufSz</a><a id="176c23" class="tk">-</a>1) ) <a id="176c29" class="tk">?</a> (<a id="176c32" class="tk">i</a><a id="176c33" class="tk">+</a>1) <a id="176c37" class="tk">:</a> 0;<span class="ct">/* move through buffer */</span></td></tr>
<tr name="177" id="177">
<td><a id="l177" class='ln'>177</a></td><td>    <span class="br">}</span></td></tr>
<tr name="178" id="178">
<td><a id="l178" class='ln'>178</a></td><td>  <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="179" id="179">
<td><a id="l179" class='ln'>179</a></td><td>    <span class="ct">/*</span></td></tr>
<tr name="180" id="180">
<td><a id="l180" class='ln'>180</a></td><td><span class="ct">     * Look backwards starting at last index which can happen when the</span></td></tr>
<tr name="181" id="181">
<td><a id="l181" class='ln'>181</a></td><td><span class="ct">     * delay time increases.</span></td></tr>
<tr name="182" id="182">
<td><a id="l182" class='ln'>182</a></td><td><span class="ct">     */</span></td></tr>
<tr name="183" id="183">
<td><a id="l183" class='ln'>183</a></td><td>    <span class="kw">while</span> (<a id="183c12" class="tk">tBuf</a>[<a id="183c17" class="tk">i</a>] <a id="183c20" class="tk">&gt;=</a> <a id="183c23" class="tk">tMinusDelay</a>) <span class="br">{</span></td></tr>
<tr name="184" id="184">
<td><a id="l184" class='ln'>184</a></td><td>      <span class="ct">/*</span></td></tr>
<tr name="185" id="185">
<td><a id="l185" class='ln'>185</a></td><td><span class="ct">       * Due to the entry condition at top of function, we</span></td></tr>
<tr name="186" id="186">
<td><a id="l186" class='ln'>186</a></td><td><span class="ct">       * should never hit the end.</span></td></tr>
<tr name="187" id="187">
<td><a id="l187" class='ln'>187</a></td><td><span class="ct">       */</span></td></tr>
<tr name="188" id="188">
<td><a id="l188" class='ln'>188</a></td><td>      <a id="188c7" class="tk">i</a> = (<a id="188c12" class="tk">i</a> <a id="188c14" class="tk">&gt;</a> 0) <a id="188c19" class="tk">?</a> <a id="188c21" class="tk">i</a><a id="188c22" class="tk">-</a>1 <a id="188c25" class="tk">:</a> (<a id="188c28" class="tk">bufSz</a><a id="188c33" class="tk">-</a>1);   <span class="ct">/* move through buffer */</span></td></tr>
<tr name="189" id="189">
<td><a id="l189" class='ln'>189</a></td><td>    <span class="br">}</span></td></tr>
<tr name="190" id="190">
<td><a id="l190" class='ln'>190</a></td><td></td></tr>
<tr name="191" id="191">
<td><a id="l191" class='ln'>191</a></td><td>    <a id="191c5" class="tk">i</a> = ( <a id="191c11" class="tk">i</a> <a id="191c13" class="tk">&lt;</a> (<a id="191c16" class="tk">bufSz</a><a id="191c21" class="tk">-</a>1) ) <a id="191c27" class="tk">?</a> (<a id="191c30" class="tk">i</a><a id="191c31" class="tk">+</a>1) <a id="191c35" class="tk">:</a> 0;</td></tr>
<tr name="192" id="192">
<td><a id="l192" class='ln'>192</a></td><td>  <span class="br">}</span></td></tr>
<tr name="193" id="193">
<td><a id="l193" class='ln'>193</a></td><td></td></tr>
<tr name="194" id="194">
<td><a id="l194" class='ln'>194</a></td><td>  <a id="194c3" class="tk">*</a><a id="194c4" class="tk">lastIdx</a> = <a id="194c14" class="tk">i</a>;</td></tr>
<tr name="195" id="195">
<td><a id="l195" class='ln'>195</a></td><td>  <span class="kw">if</span> (<a id="195c7" class="tk">discrete</a>) <span class="br">{</span></td></tr>
<tr name="196" id="196">
<td><a id="l196" class='ln'>196</a></td><td>    <span class="ct">/*</span></td></tr>
<tr name="197" id="197">
<td><a id="l197" class='ln'>197</a></td><td><span class="ct">     * tempEps = 128 * eps;</span></td></tr>
<tr name="198" id="198">
<td><a id="l198" class='ln'>198</a></td><td><span class="ct">     * localEps = max(tempEps, tempEps*fabs(tBuf[i]))/2;</span></td></tr>
<tr name="199" id="199">
<td><a id="l199" class='ln'>199</a></td><td><span class="ct">     */</span></td></tr>
<tr name="200" id="200">
<td><a id="l200" class='ln'>200</a></td><td>    <span class="kw">double</span> <a id="200c12" class="tk">tempEps</a> = (<a id="200c23" class="tk">DBL_EPSILON</a>) <a id="200c36" class="tk">*</a> 128.0;</td></tr>
<tr name="201" id="201">
<td><a id="l201" class='ln'>201</a></td><td>    <span class="kw">double</span> <a id="201c12" class="tk">localEps</a> = <a id="201c23" class="tk">tempEps</a> <a id="201c31" class="tk">*</a> <a id="201c33" class="tk">fabs</a>(<a id="201c38" class="tk">tBuf</a>[<a id="201c43" class="tk">i</a>]);</td></tr>
<tr name="202" id="202">
<td><a id="l202" class='ln'>202</a></td><td>    <span class="kw">if</span> (<a id="202c9" class="tk">tempEps</a> <a id="202c17" class="tk">&gt;</a> <a id="202c19" class="tk">localEps</a>) <span class="br">{</span></td></tr>
<tr name="203" id="203">
<td><a id="l203" class='ln'>203</a></td><td>      <a id="203c7" class="tk">localEps</a> = <a id="203c18" class="tk">tempEps</a>;</td></tr>
<tr name="204" id="204">
<td><a id="l204" class='ln'>204</a></td><td>    <span class="br">}</span></td></tr>
<tr name="205" id="205">
<td><a id="l205" class='ln'>205</a></td><td></td></tr>
<tr name="206" id="206">
<td><a id="l206" class='ln'>206</a></td><td>    <a id="206c5" class="tk">localEps</a> = <a id="206c16" class="tk">localEps</a> <a id="206c25" class="tk">/</a> 2.0;</td></tr>
<tr name="207" id="207">
<td><a id="l207" class='ln'>207</a></td><td>    <span class="kw">if</span> (<a id="207c9" class="tk">tMinusDelay</a> <a id="207c21" class="tk">&gt;=</a> (<a id="207c25" class="tk">tBuf</a>[<a id="207c30" class="tk">i</a>] <a id="207c33" class="tk">-</a> <a id="207c35" class="tk">localEps</a>)) <span class="br">{</span></td></tr>
<tr name="208" id="208">
<td><a id="l208" class='ln'>208</a></td><td>      <a id="208c7" class="tk">yout</a> = <a id="208c14" class="tk">uBuf</a>[<a id="208c19" class="tk">i</a>];</td></tr>
<tr name="209" id="209">
<td><a id="l209" class='ln'>209</a></td><td>    <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="210" id="210">
<td><a id="l210" class='ln'>210</a></td><td>      <span class="kw">if</span> (<a id="210c11" class="tk">i</a> <a id="210c13" class="tk">==</a> 0) <span class="br">{</span></td></tr>
<tr name="211" id="211">
<td><a id="l211" class='ln'>211</a></td><td>        <a id="211c9" class="tk">yout</a> = <a id="211c16" class="tk">uBuf</a>[<a id="211c21" class="tk">bufSz</a><a id="211c26" class="tk">-</a>1];</td></tr>
<tr name="212" id="212">
<td><a id="l212" class='ln'>212</a></td><td>      <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="213" id="213">
<td><a id="l213" class='ln'>213</a></td><td>        <a id="213c9" class="tk">yout</a> = <a id="213c16" class="tk">uBuf</a>[<a id="213c21" class="tk">i</a><a id="213c22" class="tk">-</a>1];</td></tr>
<tr name="214" id="214">
<td><a id="l214" class='ln'>214</a></td><td>      <span class="br">}</span></td></tr>
<tr name="215" id="215">
<td><a id="l215" class='ln'>215</a></td><td>    <span class="br">}</span></td></tr>
<tr name="216" id="216">
<td><a id="l216" class='ln'>216</a></td><td>  <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="217" id="217">
<td><a id="l217" class='ln'>217</a></td><td>    <span class="kw">if</span> (<a id="217c9" class="tk">i</a> <a id="217c11" class="tk">==</a> 0) <span class="br">{</span></td></tr>
<tr name="218" id="218">
<td><a id="l218" class='ln'>218</a></td><td>      <a id="218c7" class="tk">t1</a> = <a id="218c12" class="tk">tBuf</a>[<a id="218c17" class="tk">bufSz</a><a id="218c22" class="tk">-</a>1];</td></tr>
<tr name="219" id="219">
<td><a id="l219" class='ln'>219</a></td><td>      <a id="219c7" class="tk">u1</a> = <a id="219c12" class="tk">uBuf</a>[<a id="219c17" class="tk">bufSz</a><a id="219c22" class="tk">-</a>1];</td></tr>
<tr name="220" id="220">
<td><a id="l220" class='ln'>220</a></td><td>    <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="221" id="221">
<td><a id="l221" class='ln'>221</a></td><td>      <a id="221c7" class="tk">t1</a> = <a id="221c12" class="tk">tBuf</a>[<a id="221c17" class="tk">i</a><a id="221c18" class="tk">-</a>1];</td></tr>
<tr name="222" id="222">
<td><a id="l222" class='ln'>222</a></td><td>      <a id="222c7" class="tk">u1</a> = <a id="222c12" class="tk">uBuf</a>[<a id="222c17" class="tk">i</a><a id="222c18" class="tk">-</a>1];</td></tr>
<tr name="223" id="223">
<td><a id="l223" class='ln'>223</a></td><td>    <span class="br">}</span></td></tr>
<tr name="224" id="224">
<td><a id="l224" class='ln'>224</a></td><td></td></tr>
<tr name="225" id="225">
<td><a id="l225" class='ln'>225</a></td><td>    <a id="225c5" class="tk">t2</a> = <a id="225c10" class="tk">tBuf</a>[<a id="225c15" class="tk">i</a>];</td></tr>
<tr name="226" id="226">
<td><a id="l226" class='ln'>226</a></td><td>    <a id="226c5" class="tk">u2</a> = <a id="226c10" class="tk">uBuf</a>[<a id="226c15" class="tk">i</a>];</td></tr>
<tr name="227" id="227">
<td><a id="l227" class='ln'>227</a></td><td>    <span class="kw">if</span> (<a id="227c9" class="tk">t2</a> <a id="227c12" class="tk">==</a> <a id="227c15" class="tk">t1</a>) <span class="br">{</span></td></tr>
<tr name="228" id="228">
<td><a id="l228" class='ln'>228</a></td><td>      <span class="kw">if</span> (<a id="228c11" class="tk">tMinusDelay</a> <a id="228c23" class="tk">&gt;=</a> <a id="228c26" class="tk">t2</a>) <span class="br">{</span></td></tr>
<tr name="229" id="229">
<td><a id="l229" class='ln'>229</a></td><td>        <a id="229c9" class="tk">yout</a> = <a id="229c16" class="tk">u2</a>;</td></tr>
<tr name="230" id="230">
<td><a id="l230" class='ln'>230</a></td><td>      <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="231" id="231">
<td><a id="l231" class='ln'>231</a></td><td>        <a id="231c9" class="tk">yout</a> = <a id="231c16" class="tk">u1</a>;</td></tr>
<tr name="232" id="232">
<td><a id="l232" class='ln'>232</a></td><td>      <span class="br">}</span></td></tr>
<tr name="233" id="233">
<td><a id="l233" class='ln'>233</a></td><td>    <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="234" id="234">
<td><a id="l234" class='ln'>234</a></td><td>      <a id="234c7" class="tk">real_T</a> <a id="234c14" class="tk">f1</a> = (<a id="234c20" class="tk">t2</a><a id="234c22" class="tk">-</a><a id="234c23" class="tk">tMinusDelay</a>) <a id="234c36" class="tk">/</a> (<a id="234c39" class="tk">t2</a><a id="234c41" class="tk">-</a><a id="234c42" class="tk">t1</a>);</td></tr>
<tr name="235" id="235">
<td><a id="l235" class='ln'>235</a></td><td>      <a id="235c7" class="tk">real_T</a> <a id="235c14" class="tk">f2</a> = 1.0 <a id="235c23" class="tk">-</a> <a id="235c25" class="tk">f1</a>;</td></tr>
<tr name="236" id="236">
<td><a id="l236" class='ln'>236</a></td><td></td></tr>
<tr name="237" id="237">
<td><a id="l237" class='ln'>237</a></td><td>      <span class="ct">/*</span></td></tr>
<tr name="238" id="238">
<td><a id="l238" class='ln'>238</a></td><td><span class="ct">       * Use Lagrange's interpolation formula.  Exact outputs at t1, t2.</span></td></tr>
<tr name="239" id="239">
<td><a id="l239" class='ln'>239</a></td><td><span class="ct">       */</span></td></tr>
<tr name="240" id="240">
<td><a id="l240" class='ln'>240</a></td><td>      <a id="240c7" class="tk">yout</a> = <a id="240c14" class="tk">f1</a><a id="240c16" class="tk">*</a><a id="240c17" class="tk">u1</a> <a id="240c20" class="tk">+</a> <a id="240c22" class="tk">f2</a><a id="240c24" class="tk">*</a><a id="240c25" class="tk">u2</a>;</td></tr>
<tr name="241" id="241">
<td><a id="l241" class='ln'>241</a></td><td>    <span class="br">}</span></td></tr>
<tr name="242" id="242">
<td><a id="l242" class='ln'>242</a></td><td>  <span class="br">}</span></td></tr>
<tr name="243" id="243">
<td><a id="l243" class='ln'>243</a></td><td></td></tr>
<tr name="244" id="244">
<td><a id="l244" class='ln'>244</a></td><td>  <span class="kw">return</span>(<a id="244c10" class="tk">yout</a>);</td></tr>
<tr name="245" id="245">
<td><a id="l245" class='ln'>245</a></td><td><span class="br">}</span></td></tr>
<tr name="246" id="246">
<td><a id="l246" class='ln'>246</a></td><td></td></tr>
<tr name="247" id="247">
<td><a id="l247" class='ln'>247</a></td><td><span class="ct">/*</span></td></tr>
<tr name="248" id="248">
<td><a id="l248" class='ln'>248</a></td><td><span class="ct"> * This function updates continuous states using the ODE3 fixed-step</span></td></tr>
<tr name="249" id="249">
<td><a id="l249" class='ln'>249</a></td><td><span class="ct"> * solver algorithm</span></td></tr>
<tr name="250" id="250">
<td><a id="l250" class='ln'>250</a></td><td><span class="ct"> */</span></td></tr>
<tr name="251" id="251">
<td><a id="l251" class='ln'>251</a></td><td><span class="kw">static</span> <span class="kw">void</span> <a id="251c13" class="tk">rt_ertODEUpdateContinuousStates</a>(<a id="251c45" class="tk">RTWSolverInfo</a> <a id="251c59" class="tk">*</a><a id="251c60" class="tk">si</a> )</td></tr>
<tr name="252" id="252">
<td><a id="l252" class='ln'>252</a></td><td><span class="br">{</span></td></tr>
<tr name="253" id="253">
<td><a id="l253" class='ln'>253</a></td><td>  <span class="ct">/* Solver Matrices */</span></td></tr>
<tr name="254" id="254">
<td><a id="l254" class='ln'>254</a></td><td>  <span class="kw">static</span> <span class="kw">const</span> <a id="254c16" class="tk">real_T</a> <a id="254c23" class="tk">rt_ODE3_A</a>[3] = <span class="br">{</span></td></tr>
<tr name="255" id="255">
<td><a id="l255" class='ln'>255</a></td><td>    1.0<a id="255c8" class="tk">/</a>2.0, 3.0<a id="255c17" class="tk">/</a>4.0, 1.0</td></tr>
<tr name="256" id="256">
<td><a id="l256" class='ln'>256</a></td><td>  <span class="br">}</span>;</td></tr>
<tr name="257" id="257">
<td><a id="l257" class='ln'>257</a></td><td></td></tr>
<tr name="258" id="258">
<td><a id="l258" class='ln'>258</a></td><td>  <span class="kw">static</span> <span class="kw">const</span> <a id="258c16" class="tk">real_T</a> <a id="258c23" class="tk">rt_ODE3_B</a>[3][3] = <span class="br">{</span></td></tr>
<tr name="259" id="259">
<td><a id="l259" class='ln'>259</a></td><td>    <span class="br">{</span> 1.0<a id="259c10" class="tk">/</a>2.0, 0.0, 0.0 <span class="br">}</span>,</td></tr>
<tr name="260" id="260">
<td><a id="l260" class='ln'>260</a></td><td></td></tr>
<tr name="261" id="261">
<td><a id="l261" class='ln'>261</a></td><td>    <span class="br">{</span> 0.0, 3.0<a id="261c15" class="tk">/</a>4.0, 0.0 <span class="br">}</span>,</td></tr>
<tr name="262" id="262">
<td><a id="l262" class='ln'>262</a></td><td></td></tr>
<tr name="263" id="263">
<td><a id="l263" class='ln'>263</a></td><td>    <span class="br">{</span> 2.0<a id="263c10" class="tk">/</a>9.0, 1.0<a id="263c19" class="tk">/</a>3.0, 4.0<a id="263c28" class="tk">/</a>9.0 <span class="br">}</span></td></tr>
<tr name="264" id="264">
<td><a id="l264" class='ln'>264</a></td><td>  <span class="br">}</span>;</td></tr>
<tr name="265" id="265">
<td><a id="l265" class='ln'>265</a></td><td></td></tr>
<tr name="266" id="266">
<td><a id="l266" class='ln'>266</a></td><td>  <a id="266c3" class="tk">time_T</a> <a id="266c10" class="tk">t</a> = <a id="266c14" class="tk">rtsiGetT</a>(<a id="266c23" class="tk">si</a>);</td></tr>
<tr name="267" id="267">
<td><a id="l267" class='ln'>267</a></td><td>  <a id="267c3" class="tk">time_T</a> <a id="267c10" class="tk">tnew</a> = <a id="267c17" class="tk">rtsiGetSolverStopTime</a>(<a id="267c39" class="tk">si</a>);</td></tr>
<tr name="268" id="268">
<td><a id="l268" class='ln'>268</a></td><td>  <a id="268c3" class="tk">time_T</a> <a id="268c10" class="tk">h</a> = <a id="268c14" class="tk">rtsiGetStepSize</a>(<a id="268c30" class="tk">si</a>);</td></tr>
<tr name="269" id="269">
<td><a id="l269" class='ln'>269</a></td><td>  <a id="269c3" class="tk">real_T</a> <a id="269c10" class="tk">*</a><a id="269c11" class="tk">x</a> = <a id="269c15" class="tk">rtsiGetContStates</a>(<a id="269c33" class="tk">si</a>);</td></tr>
<tr name="270" id="270">
<td><a id="l270" class='ln'>270</a></td><td>  <a id="270c3" class="tk">ODE3_IntgData</a> <a id="270c17" class="tk">*</a><a id="270c18" class="tk">id</a> = (<a id="270c24" class="tk">ODE3_IntgData</a> <a id="270c38" class="tk">*</a>)<a id="270c40" class="tk">rtsiGetSolverData</a>(<a id="270c58" class="tk">si</a>);</td></tr>
<tr name="271" id="271">
<td><a id="l271" class='ln'>271</a></td><td>  <a id="271c3" class="tk">real_T</a> <a id="271c10" class="tk">*</a><a id="271c11" class="tk">y</a> = <a id="271c15" class="tk">id</a>-&gt;<a id="271c19" class="tk">y</a>;</td></tr>
<tr name="272" id="272">
<td><a id="l272" class='ln'>272</a></td><td>  <a id="272c3" class="tk">real_T</a> <a id="272c10" class="tk">*</a><a id="272c11" class="tk">f0</a> = <a id="272c16" class="tk">id</a>-&gt;<a id="272c20" class="tk">f</a>[0];</td></tr>
<tr name="273" id="273">
<td><a id="l273" class='ln'>273</a></td><td>  <a id="273c3" class="tk">real_T</a> <a id="273c10" class="tk">*</a><a id="273c11" class="tk">f1</a> = <a id="273c16" class="tk">id</a>-&gt;<a id="273c20" class="tk">f</a>[1];</td></tr>
<tr name="274" id="274">
<td><a id="l274" class='ln'>274</a></td><td>  <a id="274c3" class="tk">real_T</a> <a id="274c10" class="tk">*</a><a id="274c11" class="tk">f2</a> = <a id="274c16" class="tk">id</a>-&gt;<a id="274c20" class="tk">f</a>[2];</td></tr>
<tr name="275" id="275">
<td><a id="l275" class='ln'>275</a></td><td>  <a id="275c3" class="tk">real_T</a> <a id="275c10" class="tk">hB</a>[3];</td></tr>
<tr name="276" id="276">
<td><a id="l276" class='ln'>276</a></td><td>  <a id="276c3" class="tk">int_T</a> <a id="276c9" class="tk">i</a>;</td></tr>
<tr name="277" id="277">
<td><a id="l277" class='ln'>277</a></td><td>  <a id="277c3" class="tk">int_T</a> <a id="277c9" class="tk">nXc</a> = 2;</td></tr>
<tr name="278" id="278">
<td><a id="l278" class='ln'>278</a></td><td>  <a id="278c3" class="tk">rtsiSetSimTimeStep</a>(<a id="278c22" class="tk">si</a>,<a id="278c25" class="tk">MINOR_TIME_STEP</a>);</td></tr>
<tr name="279" id="279">
<td><a id="l279" class='ln'>279</a></td><td></td></tr>
<tr name="280" id="280">
<td><a id="l280" class='ln'>280</a></td><td>  <span class="ct">/* Save the state values at time t in y, we'll use x as ynew. */</span></td></tr>
<tr name="281" id="281">
<td><a id="l281" class='ln'>281</a></td><td>  (<span class="kw">void</span>) <a id="281c10" class="tk">memcpy</a>(<a id="281c17" class="tk">y</a>, <a id="281c20" class="tk">x</a>,</td></tr>
<tr name="282" id="282">
<td><a id="l282" class='ln'>282</a></td><td>                (<a id="282c18" class="tk">uint_T</a>)<a id="282c25" class="tk">nXc</a><a id="282c28" class="tk">*</a><span class="kw">sizeof</span>(<a id="282c36" class="tk">real_T</a>));</td></tr>
<tr name="283" id="283">
<td><a id="l283" class='ln'>283</a></td><td></td></tr>
<tr name="284" id="284">
<td><a id="l284" class='ln'>284</a></td><td>  <span class="ct">/* Assumes that rtsiSetT and ModelOutputs are up-to-date */</span></td></tr>
<tr name="285" id="285">
<td><a id="l285" class='ln'>285</a></td><td>  <span class="ct">/* f0 = f(t,y) */</span></td></tr>
<tr name="286" id="286">
<td><a id="l286" class='ln'>286</a></td><td>  <a id="286c3" class="tk">rtsiSetdX</a>(<a id="286c13" class="tk">si</a>, <a id="286c17" class="tk">f0</a>);</td></tr>
<tr name="287" id="287">
<td><a id="l287" class='ln'>287</a></td><td>  <a id="287c3" class="tk">tank_derivatives</a>();</td></tr>
<tr name="288" id="288">
<td><a id="l288" class='ln'>288</a></td><td></td></tr>
<tr name="289" id="289">
<td><a id="l289" class='ln'>289</a></td><td>  <span class="ct">/* f(:,2) = feval(odefile, t + hA(1), y + f*hB(:,1), args(:)(*)); */</span></td></tr>
<tr name="290" id="290">
<td><a id="l290" class='ln'>290</a></td><td>  <a id="290c3" class="tk">hB</a>[0] = <a id="290c11" class="tk">h</a> <a id="290c13" class="tk">*</a> <a id="290c15" class="tk">rt_ODE3_B</a>[0][0];</td></tr>
<tr name="291" id="291">
<td><a id="l291" class='ln'>291</a></td><td>  <span class="kw">for</span> (<a id="291c8" class="tk">i</a> = 0; <a id="291c15" class="tk">i</a> <a id="291c17" class="tk">&lt;</a> <a id="291c19" class="tk">nXc</a>; <a id="291c24" class="tk">i</a><a id="291c25" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="292" id="292">
<td><a id="l292" class='ln'>292</a></td><td>    <a id="292c5" class="tk">x</a>[<a id="292c7" class="tk">i</a>] = <a id="292c12" class="tk">y</a>[<a id="292c14" class="tk">i</a>] <a id="292c17" class="tk">+</a> (<a id="292c20" class="tk">f0</a>[<a id="292c23" class="tk">i</a>]<a id="292c25" class="tk">*</a><a id="292c26" class="tk">hB</a>[0]);</td></tr>
<tr name="293" id="293">
<td><a id="l293" class='ln'>293</a></td><td>  <span class="br">}</span></td></tr>
<tr name="294" id="294">
<td><a id="l294" class='ln'>294</a></td><td></td></tr>
<tr name="295" id="295">
<td><a id="l295" class='ln'>295</a></td><td>  <a id="295c3" class="tk">rtsiSetT</a>(<a id="295c12" class="tk">si</a>, <a id="295c16" class="tk">t</a> <a id="295c18" class="tk">+</a> <a id="295c20" class="tk">h</a><a id="295c21" class="tk">*</a><a id="295c22" class="tk">rt_ODE3_A</a>[0]);</td></tr>
<tr name="296" id="296">
<td><a id="l296" class='ln'>296</a></td><td>  <a id="296c3" class="tk">rtsiSetdX</a>(<a id="296c13" class="tk">si</a>, <a id="296c17" class="tk">f1</a>);</td></tr>
<tr name="297" id="297">
<td><a id="l297" class='ln'>297</a></td><td>  <a id="297c3" class="tk">tank_step</a>();</td></tr>
<tr name="298" id="298">
<td><a id="l298" class='ln'>298</a></td><td>  <a id="298c3" class="tk">tank_derivatives</a>();</td></tr>
<tr name="299" id="299">
<td><a id="l299" class='ln'>299</a></td><td></td></tr>
<tr name="300" id="300">
<td><a id="l300" class='ln'>300</a></td><td>  <span class="ct">/* f(:,3) = feval(odefile, t + hA(2), y + f*hB(:,2), args(:)(*)); */</span></td></tr>
<tr name="301" id="301">
<td><a id="l301" class='ln'>301</a></td><td>  <span class="kw">for</span> (<a id="301c8" class="tk">i</a> = 0; <a id="301c15" class="tk">i</a> <a id="301c17" class="tk">&lt;=</a> 1; <a id="301c23" class="tk">i</a><a id="301c24" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="302" id="302">
<td><a id="l302" class='ln'>302</a></td><td>    <a id="302c5" class="tk">hB</a>[<a id="302c8" class="tk">i</a>] = <a id="302c13" class="tk">h</a> <a id="302c15" class="tk">*</a> <a id="302c17" class="tk">rt_ODE3_B</a>[1][<a id="302c30" class="tk">i</a>];</td></tr>
<tr name="303" id="303">
<td><a id="l303" class='ln'>303</a></td><td>  <span class="br">}</span></td></tr>
<tr name="304" id="304">
<td><a id="l304" class='ln'>304</a></td><td></td></tr>
<tr name="305" id="305">
<td><a id="l305" class='ln'>305</a></td><td>  <span class="kw">for</span> (<a id="305c8" class="tk">i</a> = 0; <a id="305c15" class="tk">i</a> <a id="305c17" class="tk">&lt;</a> <a id="305c19" class="tk">nXc</a>; <a id="305c24" class="tk">i</a><a id="305c25" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="306" id="306">
<td><a id="l306" class='ln'>306</a></td><td>    <a id="306c5" class="tk">x</a>[<a id="306c7" class="tk">i</a>] = <a id="306c12" class="tk">y</a>[<a id="306c14" class="tk">i</a>] <a id="306c17" class="tk">+</a> (<a id="306c20" class="tk">f0</a>[<a id="306c23" class="tk">i</a>]<a id="306c25" class="tk">*</a><a id="306c26" class="tk">hB</a>[0] <a id="306c32" class="tk">+</a> <a id="306c34" class="tk">f1</a>[<a id="306c37" class="tk">i</a>]<a id="306c39" class="tk">*</a><a id="306c40" class="tk">hB</a>[1]);</td></tr>
<tr name="307" id="307">
<td><a id="l307" class='ln'>307</a></td><td>  <span class="br">}</span></td></tr>
<tr name="308" id="308">
<td><a id="l308" class='ln'>308</a></td><td></td></tr>
<tr name="309" id="309">
<td><a id="l309" class='ln'>309</a></td><td>  <a id="309c3" class="tk">rtsiSetT</a>(<a id="309c12" class="tk">si</a>, <a id="309c16" class="tk">t</a> <a id="309c18" class="tk">+</a> <a id="309c20" class="tk">h</a><a id="309c21" class="tk">*</a><a id="309c22" class="tk">rt_ODE3_A</a>[1]);</td></tr>
<tr name="310" id="310">
<td><a id="l310" class='ln'>310</a></td><td>  <a id="310c3" class="tk">rtsiSetdX</a>(<a id="310c13" class="tk">si</a>, <a id="310c17" class="tk">f2</a>);</td></tr>
<tr name="311" id="311">
<td><a id="l311" class='ln'>311</a></td><td>  <a id="311c3" class="tk">tank_step</a>();</td></tr>
<tr name="312" id="312">
<td><a id="l312" class='ln'>312</a></td><td>  <a id="312c3" class="tk">tank_derivatives</a>();</td></tr>
<tr name="313" id="313">
<td><a id="l313" class='ln'>313</a></td><td></td></tr>
<tr name="314" id="314">
<td><a id="l314" class='ln'>314</a></td><td>  <span class="ct">/* tnew = t + hA(3);</span></td></tr>
<tr name="315" id="315">
<td><a id="l315" class='ln'>315</a></td><td><span class="ct">     ynew = y + f*hB(:,3); */</span></td></tr>
<tr name="316" id="316">
<td><a id="l316" class='ln'>316</a></td><td>  <span class="kw">for</span> (<a id="316c8" class="tk">i</a> = 0; <a id="316c15" class="tk">i</a> <a id="316c17" class="tk">&lt;=</a> 2; <a id="316c23" class="tk">i</a><a id="316c24" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="317" id="317">
<td><a id="l317" class='ln'>317</a></td><td>    <a id="317c5" class="tk">hB</a>[<a id="317c8" class="tk">i</a>] = <a id="317c13" class="tk">h</a> <a id="317c15" class="tk">*</a> <a id="317c17" class="tk">rt_ODE3_B</a>[2][<a id="317c30" class="tk">i</a>];</td></tr>
<tr name="318" id="318">
<td><a id="l318" class='ln'>318</a></td><td>  <span class="br">}</span></td></tr>
<tr name="319" id="319">
<td><a id="l319" class='ln'>319</a></td><td></td></tr>
<tr name="320" id="320">
<td><a id="l320" class='ln'>320</a></td><td>  <span class="kw">for</span> (<a id="320c8" class="tk">i</a> = 0; <a id="320c15" class="tk">i</a> <a id="320c17" class="tk">&lt;</a> <a id="320c19" class="tk">nXc</a>; <a id="320c24" class="tk">i</a><a id="320c25" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="321" id="321">
<td><a id="l321" class='ln'>321</a></td><td>    <a id="321c5" class="tk">x</a>[<a id="321c7" class="tk">i</a>] = <a id="321c12" class="tk">y</a>[<a id="321c14" class="tk">i</a>] <a id="321c17" class="tk">+</a> (<a id="321c20" class="tk">f0</a>[<a id="321c23" class="tk">i</a>]<a id="321c25" class="tk">*</a><a id="321c26" class="tk">hB</a>[0] <a id="321c32" class="tk">+</a> <a id="321c34" class="tk">f1</a>[<a id="321c37" class="tk">i</a>]<a id="321c39" class="tk">*</a><a id="321c40" class="tk">hB</a>[1] <a id="321c46" class="tk">+</a> <a id="321c48" class="tk">f2</a>[<a id="321c51" class="tk">i</a>]<a id="321c53" class="tk">*</a><a id="321c54" class="tk">hB</a>[2]);</td></tr>
<tr name="322" id="322">
<td><a id="l322" class='ln'>322</a></td><td>  <span class="br">}</span></td></tr>
<tr name="323" id="323">
<td><a id="l323" class='ln'>323</a></td><td></td></tr>
<tr name="324" id="324">
<td><a id="l324" class='ln'>324</a></td><td>  <a id="324c3" class="tk">rtsiSetT</a>(<a id="324c12" class="tk">si</a>, <a id="324c16" class="tk">tnew</a>);</td></tr>
<tr name="325" id="325">
<td><a id="l325" class='ln'>325</a></td><td>  <a id="325c3" class="tk">rtsiSetSimTimeStep</a>(<a id="325c22" class="tk">si</a>,<a id="325c25" class="tk">MAJOR_TIME_STEP</a>);</td></tr>
<tr name="326" id="326">
<td><a id="l326" class='ln'>326</a></td><td><span class="br">}</span></td></tr>
<tr name="327" id="327">
<td><a id="l327" class='ln'>327</a></td><td></td></tr>
<tr name="328" id="328">
<td><a id="l328" class='ln'>328</a></td><td><span class="ct">/* Model step function */</span></td></tr>
<tr name="329" id="329">
<td><a id="l329" class='ln'>329</a></td><td><span class="kw">void</span> <a id="329c6" class="tk">tank_step</a>(<span class="kw">void</span>)</td></tr>
<tr name="330" id="330">
<td><a id="l330" class='ln'>330</a></td><td><span class="br">{</span></td></tr>
<tr name="331" id="331">
<td><a id="l331" class='ln'>331</a></td><td>  <span class="ct">/* local block i/o variables */</span></td></tr>
<tr name="332" id="332">
<td><a id="l332" class='ln'>332</a></td><td>  <a id="332c3" class="tk">real_T</a> <a id="332c10" class="tk">rtb_TransportDelay</a>;</td></tr>
<tr name="333" id="333">
<td><a id="l333" class='ln'>333</a></td><td>  <a id="333c3" class="tk">real_T</a> <a id="333c10" class="tk">rtb_uarea</a>;</td></tr>
<tr name="334" id="334">
<td><a id="l334" class='ln'>334</a></td><td>  <a id="334c3" class="tk">real_T</a> <a id="334c10" class="tk">rtb_sum</a>;</td></tr>
<tr name="335" id="335">
<td><a id="l335" class='ln'>335</a></td><td>  <span class="kw">if</span> (<a id="335c7" class="tk">rtmIsMajorTimeStep</a>(<a id="335c26" class="tk">tank_M</a>)) <span class="br">{</span></td></tr>
<tr name="336" id="336">
<td><a id="l336" class='ln'>336</a></td><td>    <span class="ct">/* set solver stop time */</span></td></tr>
<tr name="337" id="337">
<td><a id="l337" class='ln'>337</a></td><td>    <a id="337c5" class="tk">rtsiSetSolverStopTime</a>(<a id="337c27" class="tk">&amp;</a><a id="337c28" class="tk">tank_M</a>-&gt;<a id="337c36" class="tk">solverInfo</a>,((<a id="337c49" class="tk">tank_M</a>-&gt;<a id="337c57" class="tk">Timing</a>.<a id="337c64" class="tk">clockTick0</a><a id="337c74" class="tk">+</a>1)<a id="337c77" class="tk">*</a></td></tr>
<tr name="338" id="338">
<td><a id="l338" class='ln'>338</a></td><td>      <a id="338c7" class="tk">tank_M</a>-&gt;<a id="338c15" class="tk">Timing</a>.<a id="338c22" class="tk">stepSize0</a>));</td></tr>
<tr name="339" id="339">
<td><a id="l339" class='ln'>339</a></td><td>  <span class="br">}</span>                                    <span class="ct">/* end MajorTimeStep */</span></td></tr>
<tr name="340" id="340">
<td><a id="l340" class='ln'>340</a></td><td></td></tr>
<tr name="341" id="341">
<td><a id="l341" class='ln'>341</a></td><td>  <span class="ct">/* Update absolute time of base rate at minor time step */</span></td></tr>
<tr name="342" id="342">
<td><a id="l342" class='ln'>342</a></td><td>  <span class="kw">if</span> (<a id="342c7" class="tk">rtmIsMinorTimeStep</a>(<a id="342c26" class="tk">tank_M</a>)) <span class="br">{</span></td></tr>
<tr name="343" id="343">
<td><a id="l343" class='ln'>343</a></td><td>    <a id="343c5" class="tk">tank_M</a>-&gt;<a id="343c13" class="tk">Timing</a>.<a id="343c20" class="tk">t</a>[0] = <a id="343c27" class="tk">rtsiGetT</a>(<a id="343c36" class="tk">&amp;</a><a id="343c37" class="tk">tank_M</a>-&gt;<a id="343c45" class="tk">solverInfo</a>);</td></tr>
<tr name="344" id="344">
<td><a id="l344" class='ln'>344</a></td><td>  <span class="br">}</span></td></tr>
<tr name="345" id="345">
<td><a id="l345" class='ln'>345</a></td><td></td></tr>
<tr name="346" id="346">
<td><a id="l346" class='ln'>346</a></td><td>  <span class="ct">/* Saturate: '<a class="ct blk" blk_line="346">&lt;S4&gt;/Saturation</a>' incorporates:</span></td></tr>
<tr name="347" id="347">
<td><a id="l347" class='ln'>347</a></td><td><span class="ct">   *  Integrator: '<a class="ct blk" blk_line="347">&lt;S4&gt;/Integrator</a>'</span></td></tr>
<tr name="348" id="348">
<td><a id="l348" class='ln'>348</a></td><td><span class="ct">   */</span></td></tr>
<tr name="349" id="349">
<td><a id="l349" class='ln'>349</a></td><td>  <a id="349c3" class="tk">rtb_uarea</a> = <a id="349c15" class="tk">heightoftank</a> <a id="349c28" class="tk">*</a> <a id="349c30" class="tk">buttomarea</a>;</td></tr>
<tr name="350" id="350">
<td><a id="l350" class='ln'>350</a></td><td>  <span class="kw">if</span> (<a id="350c7" class="tk">!</a>(<a id="350c9" class="tk">tank_X</a>.<a id="350c16" class="tk">Integrator_CSTATE</a> <a id="350c34" class="tk">&gt;</a> <a id="350c36" class="tk">rtb_uarea</a>)) <span class="br">{</span></td></tr>
<tr name="351" id="351">
<td><a id="l351" class='ln'>351</a></td><td>    <span class="kw">if</span> (<a id="351c9" class="tk">tank_X</a>.<a id="351c16" class="tk">Integrator_CSTATE</a> <a id="351c34" class="tk">&lt;</a> <a id="351c36" class="tk">tank_P</a>.<a id="351c43" class="tk">tankvolume_lb</a>) <span class="br">{</span></td></tr>
<tr name="352" id="352">
<td><a id="l352" class='ln'>352</a></td><td>      <a id="352c7" class="tk">rtb_uarea</a> = <a id="352c19" class="tk">tank_P</a>.<a id="352c26" class="tk">tankvolume_lb</a>;</td></tr>
<tr name="353" id="353">
<td><a id="l353" class='ln'>353</a></td><td>    <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="354" id="354">
<td><a id="l354" class='ln'>354</a></td><td>      <a id="354c7" class="tk">rtb_uarea</a> = <a id="354c19" class="tk">tank_X</a>.<a id="354c26" class="tk">Integrator_CSTATE</a>;</td></tr>
<tr name="355" id="355">
<td><a id="l355" class='ln'>355</a></td><td>    <span class="br">}</span></td></tr>
<tr name="356" id="356">
<td><a id="l356" class='ln'>356</a></td><td>  <span class="br">}</span></td></tr>
<tr name="357" id="357">
<td><a id="l357" class='ln'>357</a></td><td></td></tr>
<tr name="358" id="358">
<td><a id="l358" class='ln'>358</a></td><td>  <span class="ct">/* End of Saturate: '<a class="ct blk" blk_line="358">&lt;S4&gt;/Saturation</a>' */</span></td></tr>
<tr name="359" id="359">
<td><a id="l359" class='ln'>359</a></td><td></td></tr>
<tr name="360" id="360">
<td><a id="l360" class='ln'>360</a></td><td>  <span class="ct">/* Gain: '<a class="ct blk" blk_line="360">&lt;S2&gt;/1//area</a>' */</span></td></tr>
<tr name="361" id="361">
<td><a id="l361" class='ln'>361</a></td><td>  <a id="361c3" class="tk">rtb_uarea</a> <a id="361c13" class="tk">*=</a> 1.0 <a id="361c20" class="tk">/</a> <a id="361c22" class="tk">buttomarea</a>;</td></tr>
<tr name="362" id="362">
<td><a id="l362" class='ln'>362</a></td><td></td></tr>
<tr name="363" id="363">
<td><a id="l363" class='ln'>363</a></td><td>  <span class="ct">/* Outport: '<a class="ct blk" blk_line="363">&lt;Root&gt;/Out1</a>' */</span></td></tr>
<tr name="364" id="364">
<td><a id="l364" class='ln'>364</a></td><td>  <a id="364c3" class="tk">tank_Y</a>.<a id="364c10" class="tk">Out1</a> = <a id="364c17" class="tk">rtb_uarea</a>;</td></tr>
<tr name="365" id="365">
<td><a id="l365" class='ln'>365</a></td><td>  <span class="kw">if</span> (<a id="365c7" class="tk">rtmIsMajorTimeStep</a>(<a id="365c26" class="tk">tank_M</a>)) <span class="br">{</span></td></tr>
<tr name="366" id="366">
<td><a id="l366" class='ln'>366</a></td><td>    <span class="ct">/* Constant: '<a class="ct blk" blk_line="366">&lt;Root&gt;/tank max inflow1 最大流量</a>' */</span></td></tr>
<tr name="367" id="367">
<td><a id="l367" class='ln'>367</a></td><td>    <a id="367c5" class="tk">tank_B</a>.<a id="367c12" class="tk">tankmaxinflow1</a> = <a id="367c29" class="tk">maxinflow</a>;</td></tr>
<tr name="368" id="368">
<td><a id="l368" class='ln'>368</a></td><td>  <span class="br">}</span></td></tr>
<tr name="369" id="369">
<td><a id="l369" class='ln'>369</a></td><td></td></tr>
<tr name="370" id="370">
<td><a id="l370" class='ln'>370</a></td><td>  <span class="ct">/* Saturate: '<a class="ct blk" blk_line="370">&lt;S3&gt;/Saturation</a>' incorporates:</span></td></tr>
<tr name="371" id="371">
<td><a id="l371" class='ln'>371</a></td><td><span class="ct">   *  Integrator: '<a class="ct blk" blk_line="371">&lt;S3&gt;/Integrator</a>'</span></td></tr>
<tr name="372" id="372">
<td><a id="l372" class='ln'>372</a></td><td><span class="ct">   */</span></td></tr>
<tr name="373" id="373">
<td><a id="l373" class='ln'>373</a></td><td>  <span class="kw">if</span> (<a id="373c7" class="tk">tank_X</a>.<a id="373c14" class="tk">Integrator_CSTATE_i</a> <a id="373c34" class="tk">&gt;</a> <a id="373c36" class="tk">tank_P</a>.<a id="373c43" class="tk">LimitedIntegrator_ub</a>) <span class="br">{</span></td></tr>
<tr name="374" id="374">
<td><a id="l374" class='ln'>374</a></td><td>    <a id="374c5" class="tk">rtb_sum</a> = <a id="374c15" class="tk">tank_P</a>.<a id="374c22" class="tk">LimitedIntegrator_ub</a>;</td></tr>
<tr name="375" id="375">
<td><a id="l375" class='ln'>375</a></td><td>  <span class="br">}</span> <span class="kw">else</span> <span class="kw">if</span> (<a id="375c14" class="tk">tank_X</a>.<a id="375c21" class="tk">Integrator_CSTATE_i</a> <a id="375c41" class="tk">&lt;</a> <a id="375c43" class="tk">tank_P</a>.<a id="375c50" class="tk">LimitedIntegrator_lb</a>) <span class="br">{</span></td></tr>
<tr name="376" id="376">
<td><a id="l376" class='ln'>376</a></td><td>    <a id="376c5" class="tk">rtb_sum</a> = <a id="376c15" class="tk">tank_P</a>.<a id="376c22" class="tk">LimitedIntegrator_lb</a>;</td></tr>
<tr name="377" id="377">
<td><a id="l377" class='ln'>377</a></td><td>  <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="378" id="378">
<td><a id="l378" class='ln'>378</a></td><td>    <a id="378c5" class="tk">rtb_sum</a> = <a id="378c15" class="tk">tank_X</a>.<a id="378c22" class="tk">Integrator_CSTATE_i</a>;</td></tr>
<tr name="379" id="379">
<td><a id="l379" class='ln'>379</a></td><td>  <span class="br">}</span></td></tr>
<tr name="380" id="380">
<td><a id="l380" class='ln'>380</a></td><td></td></tr>
<tr name="381" id="381">
<td><a id="l381" class='ln'>381</a></td><td>  <span class="ct">/* End of Saturate: '<a class="ct blk" blk_line="381">&lt;S3&gt;/Saturation</a>' */</span></td></tr>
<tr name="382" id="382">
<td><a id="l382" class='ln'>382</a></td><td></td></tr>
<tr name="383" id="383">
<td><a id="l383" class='ln'>383</a></td><td>  <span class="ct">/* Product: '<a class="ct blk" blk_line="383">&lt;S1&gt;/Product</a>' */</span></td></tr>
<tr name="384" id="384">
<td><a id="l384" class='ln'>384</a></td><td>  <a id="384c3" class="tk">rtb_sum</a> <a id="384c11" class="tk">*=</a> <a id="384c14" class="tk">tank_B</a>.<a id="384c21" class="tk">tankmaxinflow1</a>;</td></tr>
<tr name="385" id="385">
<td><a id="l385" class='ln'>385</a></td><td></td></tr>
<tr name="386" id="386">
<td><a id="l386" class='ln'>386</a></td><td>  <span class="ct">/* Outport: '<a class="ct blk" blk_line="386">&lt;Root&gt;/Out2</a>' */</span></td></tr>
<tr name="387" id="387">
<td><a id="l387" class='ln'>387</a></td><td>  <a id="387c3" class="tk">tank_Y</a>.<a id="387c10" class="tk">Out2</a> = <a id="387c17" class="tk">rtb_sum</a>;</td></tr>
<tr name="388" id="388">
<td><a id="l388" class='ln'>388</a></td><td></td></tr>
<tr name="389" id="389">
<td><a id="l389" class='ln'>389</a></td><td>  <span class="ct">/* TransportDelay: '<a class="ct blk" blk_line="389">&lt;Root&gt;/Transport Delay</a>' incorporates:</span></td></tr>
<tr name="390" id="390">
<td><a id="l390" class='ln'>390</a></td><td><span class="ct">   *  Inport: '<a class="ct blk" blk_line="390">&lt;Root&gt;/In1</a>'</span></td></tr>
<tr name="391" id="391">
<td><a id="l391" class='ln'>391</a></td><td><span class="ct">   */</span></td></tr>
<tr name="392" id="392">
<td><a id="l392" class='ln'>392</a></td><td>  <span class="br">{</span></td></tr>
<tr name="393" id="393">
<td><a id="l393" class='ln'>393</a></td><td>    <a id="393c5" class="tk">real_T</a> <a id="393c12" class="tk">*</a><a id="393c13" class="tk">*</a><a id="393c14" class="tk">uBuffer</a> = (<a id="393c25" class="tk">real_T</a><a id="393c31" class="tk">*</a><a id="393c32" class="tk">*</a>)<a id="393c34" class="tk">&amp;</a><a id="393c35" class="tk">tank_DW</a>.<a id="393c43" class="tk">TransportDelay_PWORK</a>.<a id="393c64" class="tk">TUbufferPtrs</a>[0];</td></tr>
<tr name="394" id="394">
<td><a id="l394" class='ln'>394</a></td><td>    <a id="394c5" class="tk">real_T</a> <a id="394c12" class="tk">*</a><a id="394c13" class="tk">*</a><a id="394c14" class="tk">tBuffer</a> = (<a id="394c25" class="tk">real_T</a><a id="394c31" class="tk">*</a><a id="394c32" class="tk">*</a>)<a id="394c34" class="tk">&amp;</a><a id="394c35" class="tk">tank_DW</a>.<a id="394c43" class="tk">TransportDelay_PWORK</a>.<a id="394c64" class="tk">TUbufferPtrs</a>[1];</td></tr>
<tr name="395" id="395">
<td><a id="l395" class='ln'>395</a></td><td>    <a id="395c5" class="tk">real_T</a> <a id="395c12" class="tk">simTime</a> = <a id="395c22" class="tk">tank_M</a>-&gt;<a id="395c30" class="tk">Timing</a>.<a id="395c37" class="tk">t</a>[0];</td></tr>
<tr name="396" id="396">
<td><a id="l396" class='ln'>396</a></td><td>    <a id="396c5" class="tk">real_T</a> <a id="396c12" class="tk">tMinusDelay</a> = <a id="396c26" class="tk">simTime</a> <a id="396c34" class="tk">-</a> <a id="396c36" class="tk">Timedelay</a>;</td></tr>
<tr name="397" id="397">
<td><a id="l397" class='ln'>397</a></td><td>    <span class="kw">if</span> (<a id="397c9" class="tk">Timedelay</a> <a id="397c19" class="tk">==</a> 0.0)</td></tr>
<tr name="398" id="398">
<td><a id="l398" class='ln'>398</a></td><td>      <a id="398c7" class="tk">rtb_TransportDelay</a> = <a id="398c28" class="tk">tank_U</a>.<a id="398c35" class="tk">In1</a>;</td></tr>
<tr name="399" id="399">
<td><a id="l399" class='ln'>399</a></td><td>    <span class="kw">else</span></td></tr>
<tr name="400" id="400">
<td><a id="l400" class='ln'>400</a></td><td>      <a id="400c7" class="tk">rtb_TransportDelay</a> = <a id="400c28" class="tk">rt_TDelayInterpolate</a>(</td></tr>
<tr name="401" id="401">
<td><a id="l401" class='ln'>401</a></td><td>        <a id="401c9" class="tk">tMinusDelay</a>,</td></tr>
<tr name="402" id="402">
<td><a id="l402" class='ln'>402</a></td><td>        0.0,</td></tr>
<tr name="403" id="403">
<td><a id="l403" class='ln'>403</a></td><td>        <a id="403c9" class="tk">*</a><a id="403c10" class="tk">tBuffer</a>,</td></tr>
<tr name="404" id="404">
<td><a id="l404" class='ln'>404</a></td><td>        <a id="404c9" class="tk">*</a><a id="404c10" class="tk">uBuffer</a>,</td></tr>
<tr name="405" id="405">
<td><a id="l405" class='ln'>405</a></td><td>        <a id="405c9" class="tk">tank_DW</a>.<a id="405c17" class="tk">TransportDelay_IWORK</a>.<a id="405c38" class="tk">CircularBufSize</a>,</td></tr>
<tr name="406" id="406">
<td><a id="l406" class='ln'>406</a></td><td>        <a id="406c9" class="tk">&amp;</a><a id="406c10" class="tk">tank_DW</a>.<a id="406c18" class="tk">TransportDelay_IWORK</a>.<a id="406c39" class="tk">Last</a>,</td></tr>
<tr name="407" id="407">
<td><a id="l407" class='ln'>407</a></td><td>        <a id="407c9" class="tk">tank_DW</a>.<a id="407c17" class="tk">TransportDelay_IWORK</a>.<a id="407c38" class="tk">Tail</a>,</td></tr>
<tr name="408" id="408">
<td><a id="l408" class='ln'>408</a></td><td>        <a id="408c9" class="tk">tank_DW</a>.<a id="408c17" class="tk">TransportDelay_IWORK</a>.<a id="408c38" class="tk">Head</a>,</td></tr>
<tr name="409" id="409">
<td><a id="l409" class='ln'>409</a></td><td>        <a id="409c9" class="tk">tank_P</a>.<a id="409c16" class="tk">TransportDelay_InitOutput</a>,</td></tr>
<tr name="410" id="410">
<td><a id="l410" class='ln'>410</a></td><td>        0,</td></tr>
<tr name="411" id="411">
<td><a id="l411" class='ln'>411</a></td><td>        0);</td></tr>
<tr name="412" id="412">
<td><a id="l412" class='ln'>412</a></td><td>  <span class="br">}</span></td></tr>
<tr name="413" id="413">
<td><a id="l413" class='ln'>413</a></td><td></td></tr>
<tr name="414" id="414">
<td><a id="l414" class='ln'>414</a></td><td>  <span class="ct">/* Fcn: '<a class="ct blk" blk_line="414">&lt;S3&gt;/Fcn</a>' incorporates:</span></td></tr>
<tr name="415" id="415">
<td><a id="l415" class='ln'>415</a></td><td><span class="ct">   *  Integrator: '<a class="ct blk" blk_line="415">&lt;S3&gt;/Integrator</a>'</span></td></tr>
<tr name="416" id="416">
<td><a id="l416" class='ln'>416</a></td><td><span class="ct">   */</span></td></tr>
<tr name="417" id="417">
<td><a id="l417" class='ln'>417</a></td><td>  <a id="417c3" class="tk">tank_B</a>.<a id="417c10" class="tk">Fcn</a> = (<a id="417c17" class="tk">real_T</a>)(((<a id="417c27" class="tk">tank_X</a>.<a id="417c34" class="tk">Integrator_CSTATE_i</a> <a id="417c54" class="tk">&gt;</a> 0.0) <a id="417c61" class="tk">+</a></td></tr>
<tr name="418" id="418">
<td><a id="l418" class='ln'>418</a></td><td>    (<a id="418c6" class="tk">rtb_TransportDelay</a> <a id="418c25" class="tk">&gt;=</a> 0.0) <a id="418c33" class="tk">&gt;</a> (<a id="418c36" class="tk">int32_T</a>)0.0) <a id="418c49" class="tk">*</a> ((<a id="418c53" class="tk">tank_X</a>.<a id="418c60" class="tk">Integrator_CSTATE_i</a> <a id="418c80" class="tk">&lt;</a></td></tr>
<tr name="419" id="419">
<td><a id="l419" class='ln'>419</a></td><td>    1.0) <a id="419c10" class="tk">+</a> (<a id="419c13" class="tk">rtb_TransportDelay</a> <a id="419c32" class="tk">&lt;=</a> 0.0) <a id="419c40" class="tk">&gt;</a> (<a id="419c43" class="tk">int32_T</a>)0.0)) <a id="419c57" class="tk">*</a> <a id="419c59" class="tk">rtb_TransportDelay</a>;</td></tr>
<tr name="420" id="420">
<td><a id="l420" class='ln'>420</a></td><td></td></tr>
<tr name="421" id="421">
<td><a id="l421" class='ln'>421</a></td><td>  <span class="ct">/* Fcn: '<a class="ct blk" blk_line="421">&lt;S2&gt;/sqrt(2gh)</a>' */</span></td></tr>
<tr name="422" id="422">
<td><a id="l422" class='ln'>422</a></td><td>  <a id="422c3" class="tk">rtb_uarea</a> <a id="422c13" class="tk">*=</a> 19.6;</td></tr>
<tr name="423" id="423">
<td><a id="l423" class='ln'>423</a></td><td>  <span class="kw">if</span> (<a id="423c7" class="tk">rtb_uarea</a> <a id="423c17" class="tk">&lt;</a> 0.0) <span class="br">{</span></td></tr>
<tr name="424" id="424">
<td><a id="l424" class='ln'>424</a></td><td>    <a id="424c5" class="tk">rtb_uarea</a> = <a id="424c17" class="tk">-</a><a id="424c18" class="tk">sqrt</a>(<a id="424c23" class="tk">-</a><a id="424c24" class="tk">rtb_uarea</a>);</td></tr>
<tr name="425" id="425">
<td><a id="l425" class='ln'>425</a></td><td>  <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="426" id="426">
<td><a id="l426" class='ln'>426</a></td><td>    <a id="426c5" class="tk">rtb_uarea</a> = <a id="426c17" class="tk">sqrt</a>(<a id="426c22" class="tk">rtb_uarea</a>);</td></tr>
<tr name="427" id="427">
<td><a id="l427" class='ln'>427</a></td><td>  <span class="br">}</span></td></tr>
<tr name="428" id="428">
<td><a id="l428" class='ln'>428</a></td><td></td></tr>
<tr name="429" id="429">
<td><a id="l429" class='ln'>429</a></td><td>  <span class="ct">/* End of Fcn: '<a class="ct blk" blk_line="429">&lt;S2&gt;/sqrt(2gh)</a>' */</span></td></tr>
<tr name="430" id="430">
<td><a id="l430" class='ln'>430</a></td><td></td></tr>
<tr name="431" id="431">
<td><a id="l431" class='ln'>431</a></td><td>  <span class="ct">/* Sum: '<a class="ct blk" blk_line="431">&lt;S2&gt;/sum</a>' incorporates:</span></td></tr>
<tr name="432" id="432">
<td><a id="l432" class='ln'>432</a></td><td><span class="ct">   *  Gain: '<a class="ct blk" blk_line="432">&lt;S2&gt;/outletArea</a>'</span></td></tr>
<tr name="433" id="433">
<td><a id="l433" class='ln'>433</a></td><td><span class="ct">   */</span></td></tr>
<tr name="434" id="434">
<td><a id="l434" class='ln'>434</a></td><td>  <a id="434c3" class="tk">rtb_sum</a> <a id="434c11" class="tk">-=</a> <a id="434c14" class="tk">outpipcrosssection</a> <a id="434c33" class="tk">*</a> <a id="434c35" class="tk">rtb_uarea</a>;</td></tr>
<tr name="435" id="435">
<td><a id="l435" class='ln'>435</a></td><td></td></tr>
<tr name="436" id="436">
<td><a id="l436" class='ln'>436</a></td><td>  <span class="ct">/* Fcn: '<a class="ct blk" blk_line="436">&lt;S4&gt;/Fcn</a>' incorporates:</span></td></tr>
<tr name="437" id="437">
<td><a id="l437" class='ln'>437</a></td><td><span class="ct">   *  Integrator: '<a class="ct blk" blk_line="437">&lt;S4&gt;/Integrator</a>'</span></td></tr>
<tr name="438" id="438">
<td><a id="l438" class='ln'>438</a></td><td><span class="ct">   */</span></td></tr>
<tr name="439" id="439">
<td><a id="l439" class='ln'>439</a></td><td>  <a id="439c3" class="tk">tank_B</a>.<a id="439c10" class="tk">Fcn_i</a> = (<a id="439c19" class="tk">real_T</a>)(((<a id="439c29" class="tk">tank_X</a>.<a id="439c36" class="tk">Integrator_CSTATE</a> <a id="439c54" class="tk">&gt;</a> 0.0) <a id="439c61" class="tk">+</a> (<a id="439c64" class="tk">rtb_sum</a> <a id="439c72" class="tk">&gt;=</a> 0.0) <a id="439c80" class="tk">&gt;</a></td></tr>
<tr name="440" id="440">
<td><a id="l440" class='ln'>440</a></td><td>    (<a id="440c6" class="tk">int32_T</a>)0.0) <a id="440c19" class="tk">*</a> ((<a id="440c23" class="tk">tank_X</a>.<a id="440c30" class="tk">Integrator_CSTATE</a> <a id="440c48" class="tk">&lt;</a> 2.0) <a id="440c55" class="tk">+</a> (<a id="440c58" class="tk">rtb_sum</a> <a id="440c66" class="tk">&lt;=</a> 0.0) <a id="440c74" class="tk">&gt;</a></td></tr>
<tr name="441" id="441">
<td><a id="l441" class='ln'>441</a></td><td>                     (<a id="441c23" class="tk">int32_T</a>)0.0)) <a id="441c37" class="tk">*</a> <a id="441c39" class="tk">rtb_sum</a>;</td></tr>
<tr name="442" id="442">
<td><a id="l442" class='ln'>442</a></td><td>  <span class="kw">if</span> (<a id="442c7" class="tk">rtmIsMajorTimeStep</a>(<a id="442c26" class="tk">tank_M</a>)) <span class="br">{</span></td></tr>
<tr name="443" id="443">
<td><a id="l443" class='ln'>443</a></td><td>    <span class="ct">/* Update for TransportDelay: '<a class="ct blk" blk_line="443">&lt;Root&gt;/Transport Delay</a>' incorporates:</span></td></tr>
<tr name="444" id="444">
<td><a id="l444" class='ln'>444</a></td><td><span class="ct">     *  Inport: '<a class="ct blk" blk_line="444">&lt;Root&gt;/In1</a>'</span></td></tr>
<tr name="445" id="445">
<td><a id="l445" class='ln'>445</a></td><td><span class="ct">     */</span></td></tr>
<tr name="446" id="446">
<td><a id="l446" class='ln'>446</a></td><td>    <span class="br">{</span></td></tr>
<tr name="447" id="447">
<td><a id="l447" class='ln'>447</a></td><td>      <a id="447c7" class="tk">real_T</a> <a id="447c14" class="tk">*</a><a id="447c15" class="tk">*</a><a id="447c16" class="tk">uBuffer</a> = (<a id="447c27" class="tk">real_T</a><a id="447c33" class="tk">*</a><a id="447c34" class="tk">*</a>)<a id="447c36" class="tk">&amp;</a><a id="447c37" class="tk">tank_DW</a>.<a id="447c45" class="tk">TransportDelay_PWORK</a>.<a id="447c66" class="tk">TUbufferPtrs</a>[0];</td></tr>
<tr name="448" id="448">
<td><a id="l448" class='ln'>448</a></td><td>      <a id="448c7" class="tk">real_T</a> <a id="448c14" class="tk">*</a><a id="448c15" class="tk">*</a><a id="448c16" class="tk">tBuffer</a> = (<a id="448c27" class="tk">real_T</a><a id="448c33" class="tk">*</a><a id="448c34" class="tk">*</a>)<a id="448c36" class="tk">&amp;</a><a id="448c37" class="tk">tank_DW</a>.<a id="448c45" class="tk">TransportDelay_PWORK</a>.<a id="448c66" class="tk">TUbufferPtrs</a>[1];</td></tr>
<tr name="449" id="449">
<td><a id="l449" class='ln'>449</a></td><td>      <a id="449c7" class="tk">real_T</a> <a id="449c14" class="tk">simTime</a> = <a id="449c24" class="tk">tank_M</a>-&gt;<a id="449c32" class="tk">Timing</a>.<a id="449c39" class="tk">t</a>[0];</td></tr>
<tr name="450" id="450">
<td><a id="l450" class='ln'>450</a></td><td>      <a id="450c7" class="tk">tank_DW</a>.<a id="450c15" class="tk">TransportDelay_IWORK</a>.<a id="450c36" class="tk">Head</a> = ((<a id="450c45" class="tk">tank_DW</a>.<a id="450c53" class="tk">TransportDelay_IWORK</a>.<a id="450c74" class="tk">Head</a> <a id="450c79" class="tk">&lt;</a></td></tr>
<tr name="451" id="451">
<td><a id="l451" class='ln'>451</a></td><td>        (<a id="451c10" class="tk">tank_DW</a>.<a id="451c18" class="tk">TransportDelay_IWORK</a>.<a id="451c39" class="tk">CircularBufSize</a><a id="451c54" class="tk">-</a>1)) <a id="451c59" class="tk">?</a></td></tr>
<tr name="452" id="452">
<td><a id="l452" class='ln'>452</a></td><td>        (<a id="452c10" class="tk">tank_DW</a>.<a id="452c18" class="tk">TransportDelay_IWORK</a>.<a id="452c39" class="tk">Head</a><a id="452c43" class="tk">+</a>1) <a id="452c47" class="tk">:</a> 0);</td></tr>
<tr name="453" id="453">
<td><a id="l453" class='ln'>453</a></td><td>      <span class="kw">if</span> (<a id="453c11" class="tk">tank_DW</a>.<a id="453c19" class="tk">TransportDelay_IWORK</a>.<a id="453c40" class="tk">Head</a> <a id="453c45" class="tk">==</a> <a id="453c48" class="tk">tank_DW</a>.<a id="453c56" class="tk">TransportDelay_IWORK</a>.<a id="453c77" class="tk">Tail</a>)</td></tr>
<tr name="454" id="454">
<td><a id="l454" class='ln'>454</a></td><td>      <span class="br">{</span></td></tr>
<tr name="455" id="455">
<td><a id="l455" class='ln'>455</a></td><td>        <a id="455c9" class="tk">tank_DW</a>.<a id="455c17" class="tk">TransportDelay_IWORK</a>.<a id="455c38" class="tk">Tail</a> = ((<a id="455c47" class="tk">tank_DW</a>.<a id="455c55" class="tk">TransportDelay_IWORK</a>.<a id="455c76" class="tk">Tail</a> <a id="455c81" class="tk">&lt;</a></td></tr>
<tr name="456" id="456">
<td><a id="l456" class='ln'>456</a></td><td>          (<a id="456c12" class="tk">tank_DW</a>.<a id="456c20" class="tk">TransportDelay_IWORK</a>.<a id="456c41" class="tk">CircularBufSize</a><a id="456c56" class="tk">-</a>1)) <a id="456c61" class="tk">?</a></td></tr>
<tr name="457" id="457">
<td><a id="l457" class='ln'>457</a></td><td>          (<a id="457c12" class="tk">tank_DW</a>.<a id="457c20" class="tk">TransportDelay_IWORK</a>.<a id="457c41" class="tk">Tail</a><a id="457c45" class="tk">+</a>1) <a id="457c49" class="tk">:</a> 0);</td></tr>
<tr name="458" id="458">
<td><a id="l458" class='ln'>458</a></td><td>      <span class="br">}</span></td></tr>
<tr name="459" id="459">
<td><a id="l459" class='ln'>459</a></td><td></td></tr>
<tr name="460" id="460">
<td><a id="l460" class='ln'>460</a></td><td>      (<a id="460c8" class="tk">*</a><a id="460c9" class="tk">tBuffer</a>)[<a id="460c18" class="tk">tank_DW</a>.<a id="460c26" class="tk">TransportDelay_IWORK</a>.<a id="460c47" class="tk">Head</a>] = <a id="460c55" class="tk">simTime</a>;</td></tr>
<tr name="461" id="461">
<td><a id="l461" class='ln'>461</a></td><td>      (<a id="461c8" class="tk">*</a><a id="461c9" class="tk">uBuffer</a>)[<a id="461c18" class="tk">tank_DW</a>.<a id="461c26" class="tk">TransportDelay_IWORK</a>.<a id="461c47" class="tk">Head</a>] = <a id="461c55" class="tk">tank_U</a>.<a id="461c62" class="tk">In1</a>;</td></tr>
<tr name="462" id="462">
<td><a id="l462" class='ln'>462</a></td><td>    <span class="br">}</span></td></tr>
<tr name="463" id="463">
<td><a id="l463" class='ln'>463</a></td><td>  <span class="br">}</span>                                    <span class="ct">/* end MajorTimeStep */</span></td></tr>
<tr name="464" id="464">
<td><a id="l464" class='ln'>464</a></td><td></td></tr>
<tr name="465" id="465">
<td><a id="l465" class='ln'>465</a></td><td>  <span class="kw">if</span> (<a id="465c7" class="tk">rtmIsMajorTimeStep</a>(<a id="465c26" class="tk">tank_M</a>)) <span class="br">{</span></td></tr>
<tr name="466" id="466">
<td><a id="l466" class='ln'>466</a></td><td>    <a id="466c5" class="tk">rt_ertODEUpdateContinuousStates</a>(<a id="466c37" class="tk">&amp;</a><a id="466c38" class="tk">tank_M</a>-&gt;<a id="466c46" class="tk">solverInfo</a>);</td></tr>
<tr name="467" id="467">
<td><a id="l467" class='ln'>467</a></td><td></td></tr>
<tr name="468" id="468">
<td><a id="l468" class='ln'>468</a></td><td>    <span class="ct">/* Update absolute time for base rate */</span></td></tr>
<tr name="469" id="469">
<td><a id="l469" class='ln'>469</a></td><td>    <span class="ct">/* The "clockTick0" counts the number of times the code of this task has</span></td></tr>
<tr name="470" id="470">
<td><a id="l470" class='ln'>470</a></td><td><span class="ct">     * been executed. The absolute time is the multiplication of "clockTick0"</span></td></tr>
<tr name="471" id="471">
<td><a id="l471" class='ln'>471</a></td><td><span class="ct">     * and "Timing.stepSize0". Size of "clockTick0" ensures timer will not</span></td></tr>
<tr name="472" id="472">
<td><a id="l472" class='ln'>472</a></td><td><span class="ct">     * overflow during the application lifespan selected.</span></td></tr>
<tr name="473" id="473">
<td><a id="l473" class='ln'>473</a></td><td><span class="ct">     */</span></td></tr>
<tr name="474" id="474">
<td><a id="l474" class='ln'>474</a></td><td>    <a id="474c5" class="tk">++</a><a id="474c7" class="tk">tank_M</a>-&gt;<a id="474c15" class="tk">Timing</a>.<a id="474c22" class="tk">clockTick0</a>;</td></tr>
<tr name="475" id="475">
<td><a id="l475" class='ln'>475</a></td><td>    <a id="475c5" class="tk">tank_M</a>-&gt;<a id="475c13" class="tk">Timing</a>.<a id="475c20" class="tk">t</a>[0] = <a id="475c27" class="tk">rtsiGetSolverStopTime</a>(<a id="475c49" class="tk">&amp;</a><a id="475c50" class="tk">tank_M</a>-&gt;<a id="475c58" class="tk">solverInfo</a>);</td></tr>
<tr name="476" id="476">
<td><a id="l476" class='ln'>476</a></td><td></td></tr>
<tr name="477" id="477">
<td><a id="l477" class='ln'>477</a></td><td>    <span class="br">{</span></td></tr>
<tr name="478" id="478">
<td><a id="l478" class='ln'>478</a></td><td>      <span class="ct">/* Update absolute timer for sample time: [0.1s, 0.0s] */</span></td></tr>
<tr name="479" id="479">
<td><a id="l479" class='ln'>479</a></td><td>      <span class="ct">/* The "clockTick1" counts the number of times the code of this task has</span></td></tr>
<tr name="480" id="480">
<td><a id="l480" class='ln'>480</a></td><td><span class="ct">       * been executed. The resolution of this integer timer is 0.1, which is the step size</span></td></tr>
<tr name="481" id="481">
<td><a id="l481" class='ln'>481</a></td><td><span class="ct">       * of the task. Size of "clockTick1" ensures timer will not overflow during the</span></td></tr>
<tr name="482" id="482">
<td><a id="l482" class='ln'>482</a></td><td><span class="ct">       * application lifespan selected.</span></td></tr>
<tr name="483" id="483">
<td><a id="l483" class='ln'>483</a></td><td><span class="ct">       */</span></td></tr>
<tr name="484" id="484">
<td><a id="l484" class='ln'>484</a></td><td>      <a id="484c7" class="tk">tank_M</a>-&gt;<a id="484c15" class="tk">Timing</a>.<a id="484c22" class="tk">clockTick1</a><a id="484c32" class="tk">++</a>;</td></tr>
<tr name="485" id="485">
<td><a id="l485" class='ln'>485</a></td><td>    <span class="br">}</span></td></tr>
<tr name="486" id="486">
<td><a id="l486" class='ln'>486</a></td><td>  <span class="br">}</span>                                    <span class="ct">/* end MajorTimeStep */</span></td></tr>
<tr name="487" id="487">
<td><a id="l487" class='ln'>487</a></td><td><span class="br">}</span></td></tr>
<tr name="488" id="488">
<td><a id="l488" class='ln'>488</a></td><td></td></tr>
<tr name="489" id="489">
<td><a id="l489" class='ln'>489</a></td><td><span class="ct">/* Derivatives for root system: '<a class="ct blk" blk_line="489">&lt;Root&gt;</a>' */</span></td></tr>
<tr name="490" id="490">
<td><a id="l490" class='ln'>490</a></td><td><span class="kw">void</span> <a id="490c6" class="tk">tank_derivatives</a>(<span class="kw">void</span>)</td></tr>
<tr name="491" id="491">
<td><a id="l491" class='ln'>491</a></td><td><span class="br">{</span></td></tr>
<tr name="492" id="492">
<td><a id="l492" class='ln'>492</a></td><td>  <a id="492c3" class="tk">XDot_tank_T</a> <a id="492c15" class="tk">*</a><a id="492c16" class="tk">_rtXdot</a>;</td></tr>
<tr name="493" id="493">
<td><a id="l493" class='ln'>493</a></td><td>  <a id="493c3" class="tk">_rtXdot</a> = ((<a id="493c15" class="tk">XDot_tank_T</a> <a id="493c27" class="tk">*</a>) <a id="493c30" class="tk">tank_M</a>-&gt;<a id="493c38" class="tk">derivs</a>);</td></tr>
<tr name="494" id="494">
<td><a id="l494" class='ln'>494</a></td><td></td></tr>
<tr name="495" id="495">
<td><a id="l495" class='ln'>495</a></td><td>  <span class="ct">/* Derivatives for Integrator: '<a class="ct blk" blk_line="495">&lt;S4&gt;/Integrator</a>' */</span></td></tr>
<tr name="496" id="496">
<td><a id="l496" class='ln'>496</a></td><td>  <a id="496c3" class="tk">_rtXdot</a>-&gt;<a id="496c12" class="tk">Integrator_CSTATE</a> = <a id="496c32" class="tk">tank_B</a>.<a id="496c39" class="tk">Fcn_i</a>;</td></tr>
<tr name="497" id="497">
<td><a id="l497" class='ln'>497</a></td><td></td></tr>
<tr name="498" id="498">
<td><a id="l498" class='ln'>498</a></td><td>  <span class="ct">/* Derivatives for Integrator: '<a class="ct blk" blk_line="498">&lt;S3&gt;/Integrator</a>' */</span></td></tr>
<tr name="499" id="499">
<td><a id="l499" class='ln'>499</a></td><td>  <a id="499c3" class="tk">_rtXdot</a>-&gt;<a id="499c12" class="tk">Integrator_CSTATE_i</a> = <a id="499c34" class="tk">tank_B</a>.<a id="499c41" class="tk">Fcn</a>;</td></tr>
<tr name="500" id="500">
<td><a id="l500" class='ln'>500</a></td><td><span class="br">}</span></td></tr>
<tr name="501" id="501">
<td><a id="l501" class='ln'>501</a></td><td></td></tr>
<tr name="502" id="502">
<td><a id="l502" class='ln'>502</a></td><td><span class="ct">/* Model initialize function */</span></td></tr>
<tr name="503" id="503">
<td><a id="l503" class='ln'>503</a></td><td><span class="kw">void</span> <a id="503c6" class="tk">tank_initialize</a>(<span class="kw">void</span>)</td></tr>
<tr name="504" id="504">
<td><a id="l504" class='ln'>504</a></td><td><span class="br">{</span></td></tr>
<tr name="505" id="505">
<td><a id="l505" class='ln'>505</a></td><td>  <span class="ct">/* Registration code */</span></td></tr>
<tr name="506" id="506">
<td><a id="l506" class='ln'>506</a></td><td></td></tr>
<tr name="507" id="507">
<td><a id="l507" class='ln'>507</a></td><td>  <span class="ct">/* initialize real-time model */</span></td></tr>
<tr name="508" id="508">
<td><a id="l508" class='ln'>508</a></td><td>  (<span class="kw">void</span>) <a id="508c10" class="tk">memset</a>((<span class="kw">void</span> <a id="508c23" class="tk">*</a>)<a id="508c25" class="tk">tank_M</a>, 0,</td></tr>
<tr name="509" id="509">
<td><a id="l509" class='ln'>509</a></td><td>                <span class="kw">sizeof</span>(<a id="509c24" class="tk">RT_MODEL_tank_T</a>));</td></tr>
<tr name="510" id="510">
<td><a id="l510" class='ln'>510</a></td><td></td></tr>
<tr name="511" id="511">
<td><a id="l511" class='ln'>511</a></td><td>  <span class="br">{</span></td></tr>
<tr name="512" id="512">
<td><a id="l512" class='ln'>512</a></td><td>    <span class="ct">/* Setup solver object */</span></td></tr>
<tr name="513" id="513">
<td><a id="l513" class='ln'>513</a></td><td>    <a id="513c5" class="tk">rtsiSetSimTimeStepPtr</a>(<a id="513c27" class="tk">&amp;</a><a id="513c28" class="tk">tank_M</a>-&gt;<a id="513c36" class="tk">solverInfo</a>, <a id="513c48" class="tk">&amp;</a><a id="513c49" class="tk">tank_M</a>-&gt;<a id="513c57" class="tk">Timing</a>.<a id="513c64" class="tk">simTimeStep</a>);</td></tr>
<tr name="514" id="514">
<td><a id="l514" class='ln'>514</a></td><td>    <a id="514c5" class="tk">rtsiSetTPtr</a>(<a id="514c17" class="tk">&amp;</a><a id="514c18" class="tk">tank_M</a>-&gt;<a id="514c26" class="tk">solverInfo</a>, <a id="514c38" class="tk">&amp;</a><a id="514c39" class="tk">rtmGetTPtr</a>(<a id="514c50" class="tk">tank_M</a>));</td></tr>
<tr name="515" id="515">
<td><a id="l515" class='ln'>515</a></td><td>    <a id="515c5" class="tk">rtsiSetStepSizePtr</a>(<a id="515c24" class="tk">&amp;</a><a id="515c25" class="tk">tank_M</a>-&gt;<a id="515c33" class="tk">solverInfo</a>, <a id="515c45" class="tk">&amp;</a><a id="515c46" class="tk">tank_M</a>-&gt;<a id="515c54" class="tk">Timing</a>.<a id="515c61" class="tk">stepSize0</a>);</td></tr>
<tr name="516" id="516">
<td><a id="l516" class='ln'>516</a></td><td>    <a id="516c5" class="tk">rtsiSetdXPtr</a>(<a id="516c18" class="tk">&amp;</a><a id="516c19" class="tk">tank_M</a>-&gt;<a id="516c27" class="tk">solverInfo</a>, <a id="516c39" class="tk">&amp;</a><a id="516c40" class="tk">tank_M</a>-&gt;<a id="516c48" class="tk">derivs</a>);</td></tr>
<tr name="517" id="517">
<td><a id="l517" class='ln'>517</a></td><td>    <a id="517c5" class="tk">rtsiSetContStatesPtr</a>(<a id="517c26" class="tk">&amp;</a><a id="517c27" class="tk">tank_M</a>-&gt;<a id="517c35" class="tk">solverInfo</a>, (<a id="517c48" class="tk">real_T</a> <a id="517c55" class="tk">*</a><a id="517c56" class="tk">*</a>) <a id="517c59" class="tk">&amp;</a><a id="517c60" class="tk">tank_M</a>-&gt;<a id="517c68" class="tk">contStates</a>);</td></tr>
<tr name="518" id="518">
<td><a id="l518" class='ln'>518</a></td><td>    <a id="518c5" class="tk">rtsiSetNumContStatesPtr</a>(<a id="518c29" class="tk">&amp;</a><a id="518c30" class="tk">tank_M</a>-&gt;<a id="518c38" class="tk">solverInfo</a>, <a id="518c50" class="tk">&amp;</a><a id="518c51" class="tk">tank_M</a>-&gt;<a id="518c59" class="tk">Sizes</a>.<a id="518c65" class="tk">numContStates</a>);</td></tr>
<tr name="519" id="519">
<td><a id="l519" class='ln'>519</a></td><td>    <a id="519c5" class="tk">rtsiSetNumPeriodicContStatesPtr</a>(<a id="519c37" class="tk">&amp;</a><a id="519c38" class="tk">tank_M</a>-&gt;<a id="519c46" class="tk">solverInfo</a>,</td></tr>
<tr name="520" id="520">
<td><a id="l520" class='ln'>520</a></td><td>      <a id="520c7" class="tk">&amp;</a><a id="520c8" class="tk">tank_M</a>-&gt;<a id="520c16" class="tk">Sizes</a>.<a id="520c22" class="tk">numPeriodicContStates</a>);</td></tr>
<tr name="521" id="521">
<td><a id="l521" class='ln'>521</a></td><td>    <a id="521c5" class="tk">rtsiSetPeriodicContStateIndicesPtr</a>(<a id="521c40" class="tk">&amp;</a><a id="521c41" class="tk">tank_M</a>-&gt;<a id="521c49" class="tk">solverInfo</a>,</td></tr>
<tr name="522" id="522">
<td><a id="l522" class='ln'>522</a></td><td>      <a id="522c7" class="tk">&amp;</a><a id="522c8" class="tk">tank_M</a>-&gt;<a id="522c16" class="tk">periodicContStateIndices</a>);</td></tr>
<tr name="523" id="523">
<td><a id="l523" class='ln'>523</a></td><td>    <a id="523c5" class="tk">rtsiSetPeriodicContStateRangesPtr</a>(<a id="523c39" class="tk">&amp;</a><a id="523c40" class="tk">tank_M</a>-&gt;<a id="523c48" class="tk">solverInfo</a>,</td></tr>
<tr name="524" id="524">
<td><a id="l524" class='ln'>524</a></td><td>      <a id="524c7" class="tk">&amp;</a><a id="524c8" class="tk">tank_M</a>-&gt;<a id="524c16" class="tk">periodicContStateRanges</a>);</td></tr>
<tr name="525" id="525">
<td><a id="l525" class='ln'>525</a></td><td>    <a id="525c5" class="tk">rtsiSetErrorStatusPtr</a>(<a id="525c27" class="tk">&amp;</a><a id="525c28" class="tk">tank_M</a>-&gt;<a id="525c36" class="tk">solverInfo</a>, (<a id="525c49" class="tk">&amp;</a><a id="525c50" class="tk">rtmGetErrorStatus</a>(<a id="525c68" class="tk">tank_M</a>)));</td></tr>
<tr name="526" id="526">
<td><a id="l526" class='ln'>526</a></td><td>    <a id="526c5" class="tk">rtsiSetRTModelPtr</a>(<a id="526c23" class="tk">&amp;</a><a id="526c24" class="tk">tank_M</a>-&gt;<a id="526c32" class="tk">solverInfo</a>, <a id="526c44" class="tk">tank_M</a>);</td></tr>
<tr name="527" id="527">
<td><a id="l527" class='ln'>527</a></td><td>  <span class="br">}</span></td></tr>
<tr name="528" id="528">
<td><a id="l528" class='ln'>528</a></td><td></td></tr>
<tr name="529" id="529">
<td><a id="l529" class='ln'>529</a></td><td>  <a id="529c3" class="tk">rtsiSetSimTimeStep</a>(<a id="529c22" class="tk">&amp;</a><a id="529c23" class="tk">tank_M</a>-&gt;<a id="529c31" class="tk">solverInfo</a>, <a id="529c43" class="tk">MAJOR_TIME_STEP</a>);</td></tr>
<tr name="530" id="530">
<td><a id="l530" class='ln'>530</a></td><td>  <a id="530c3" class="tk">tank_M</a>-&gt;<a id="530c11" class="tk">intgData</a>.<a id="530c20" class="tk">y</a> = <a id="530c24" class="tk">tank_M</a>-&gt;<a id="530c32" class="tk">odeY</a>;</td></tr>
<tr name="531" id="531">
<td><a id="l531" class='ln'>531</a></td><td>  <a id="531c3" class="tk">tank_M</a>-&gt;<a id="531c11" class="tk">intgData</a>.<a id="531c20" class="tk">f</a>[0] = <a id="531c27" class="tk">tank_M</a>-&gt;<a id="531c35" class="tk">odeF</a>[0];</td></tr>
<tr name="532" id="532">
<td><a id="l532" class='ln'>532</a></td><td>  <a id="532c3" class="tk">tank_M</a>-&gt;<a id="532c11" class="tk">intgData</a>.<a id="532c20" class="tk">f</a>[1] = <a id="532c27" class="tk">tank_M</a>-&gt;<a id="532c35" class="tk">odeF</a>[1];</td></tr>
<tr name="533" id="533">
<td><a id="l533" class='ln'>533</a></td><td>  <a id="533c3" class="tk">tank_M</a>-&gt;<a id="533c11" class="tk">intgData</a>.<a id="533c20" class="tk">f</a>[2] = <a id="533c27" class="tk">tank_M</a>-&gt;<a id="533c35" class="tk">odeF</a>[2];</td></tr>
<tr name="534" id="534">
<td><a id="l534" class='ln'>534</a></td><td>  <a id="534c3" class="tk">tank_M</a>-&gt;<a id="534c11" class="tk">contStates</a> = ((<a id="534c26" class="tk">X_tank_T</a> <a id="534c35" class="tk">*</a>) <a id="534c38" class="tk">&amp;</a><a id="534c39" class="tk">tank_X</a>);</td></tr>
<tr name="535" id="535">
<td><a id="l535" class='ln'>535</a></td><td>  <a id="535c3" class="tk">rtsiSetSolverData</a>(<a id="535c21" class="tk">&amp;</a><a id="535c22" class="tk">tank_M</a>-&gt;<a id="535c30" class="tk">solverInfo</a>, (<span class="kw">void</span> <a id="535c48" class="tk">*</a>)<a id="535c50" class="tk">&amp;</a><a id="535c51" class="tk">tank_M</a>-&gt;<a id="535c59" class="tk">intgData</a>);</td></tr>
<tr name="536" id="536">
<td><a id="l536" class='ln'>536</a></td><td>  <a id="536c3" class="tk">rtsiSetSolverName</a>(<a id="536c21" class="tk">&amp;</a><a id="536c22" class="tk">tank_M</a>-&gt;<a id="536c30" class="tk">solverInfo</a>,"ode3");</td></tr>
<tr name="537" id="537">
<td><a id="l537" class='ln'>537</a></td><td>  <a id="537c3" class="tk">rtmSetTPtr</a>(<a id="537c14" class="tk">tank_M</a>, <a id="537c22" class="tk">&amp;</a><a id="537c23" class="tk">tank_M</a>-&gt;<a id="537c31" class="tk">Timing</a>.<a id="537c38" class="tk">tArray</a>[0]);</td></tr>
<tr name="538" id="538">
<td><a id="l538" class='ln'>538</a></td><td>  <a id="538c3" class="tk">tank_M</a>-&gt;<a id="538c11" class="tk">Timing</a>.<a id="538c18" class="tk">stepSize0</a> = 0.1;</td></tr>
<tr name="539" id="539">
<td><a id="l539" class='ln'>539</a></td><td></td></tr>
<tr name="540" id="540">
<td><a id="l540" class='ln'>540</a></td><td>  <span class="ct">/* block I/O */</span></td></tr>
<tr name="541" id="541">
<td><a id="l541" class='ln'>541</a></td><td>  (<span class="kw">void</span>) <a id="541c10" class="tk">memset</a>(((<span class="kw">void</span> <a id="541c24" class="tk">*</a>) <a id="541c27" class="tk">&amp;</a><a id="541c28" class="tk">tank_B</a>), 0,</td></tr>
<tr name="542" id="542">
<td><a id="l542" class='ln'>542</a></td><td>                <span class="kw">sizeof</span>(<a id="542c24" class="tk">B_tank_T</a>));</td></tr>
<tr name="543" id="543">
<td><a id="l543" class='ln'>543</a></td><td></td></tr>
<tr name="544" id="544">
<td><a id="l544" class='ln'>544</a></td><td>  <span class="ct">/* states (continuous) */</span></td></tr>
<tr name="545" id="545">
<td><a id="l545" class='ln'>545</a></td><td>  <span class="br">{</span></td></tr>
<tr name="546" id="546">
<td><a id="l546" class='ln'>546</a></td><td>    (<span class="kw">void</span>) <a id="546c12" class="tk">memset</a>((<span class="kw">void</span> <a id="546c25" class="tk">*</a>)<a id="546c27" class="tk">&amp;</a><a id="546c28" class="tk">tank_X</a>, 0,</td></tr>
<tr name="547" id="547">
<td><a id="l547" class='ln'>547</a></td><td>                  <span class="kw">sizeof</span>(<a id="547c26" class="tk">X_tank_T</a>));</td></tr>
<tr name="548" id="548">
<td><a id="l548" class='ln'>548</a></td><td>  <span class="br">}</span></td></tr>
<tr name="549" id="549">
<td><a id="l549" class='ln'>549</a></td><td></td></tr>
<tr name="550" id="550">
<td><a id="l550" class='ln'>550</a></td><td>  <span class="ct">/* states (dwork) */</span></td></tr>
<tr name="551" id="551">
<td><a id="l551" class='ln'>551</a></td><td>  (<span class="kw">void</span>) <a id="551c10" class="tk">memset</a>((<span class="kw">void</span> <a id="551c23" class="tk">*</a>)<a id="551c25" class="tk">&amp;</a><a id="551c26" class="tk">tank_DW</a>, 0,</td></tr>
<tr name="552" id="552">
<td><a id="l552" class='ln'>552</a></td><td>                <span class="kw">sizeof</span>(<a id="552c24" class="tk">DW_tank_T</a>));</td></tr>
<tr name="553" id="553">
<td><a id="l553" class='ln'>553</a></td><td></td></tr>
<tr name="554" id="554">
<td><a id="l554" class='ln'>554</a></td><td>  <span class="ct">/* external inputs */</span></td></tr>
<tr name="555" id="555">
<td><a id="l555" class='ln'>555</a></td><td>  <a id="555c3" class="tk">tank_U</a>.<a id="555c10" class="tk">In1</a> = 0.0;</td></tr>
<tr name="556" id="556">
<td><a id="l556" class='ln'>556</a></td><td></td></tr>
<tr name="557" id="557">
<td><a id="l557" class='ln'>557</a></td><td>  <span class="ct">/* external outputs */</span></td></tr>
<tr name="558" id="558">
<td><a id="l558" class='ln'>558</a></td><td>  (<span class="kw">void</span>) <a id="558c10" class="tk">memset</a>((<span class="kw">void</span> <a id="558c23" class="tk">*</a>)<a id="558c25" class="tk">&amp;</a><a id="558c26" class="tk">tank_Y</a>, 0,</td></tr>
<tr name="559" id="559">
<td><a id="l559" class='ln'>559</a></td><td>                <span class="kw">sizeof</span>(<a id="559c24" class="tk">ExtY_tank_T</a>));</td></tr>
<tr name="560" id="560">
<td><a id="l560" class='ln'>560</a></td><td></td></tr>
<tr name="561" id="561">
<td><a id="l561" class='ln'>561</a></td><td>  <span class="ct">/* Start for TransportDelay: '<a class="ct blk" blk_line="561">&lt;Root&gt;/Transport Delay</a>' incorporates:</span></td></tr>
<tr name="562" id="562">
<td><a id="l562" class='ln'>562</a></td><td><span class="ct">   *  Inport: '<a class="ct blk" blk_line="562">&lt;Root&gt;/In1</a>'</span></td></tr>
<tr name="563" id="563">
<td><a id="l563" class='ln'>563</a></td><td><span class="ct">   */</span></td></tr>
<tr name="564" id="564">
<td><a id="l564" class='ln'>564</a></td><td>  <span class="br">{</span></td></tr>
<tr name="565" id="565">
<td><a id="l565" class='ln'>565</a></td><td>    <a id="565c5" class="tk">real_T</a> <a id="565c12" class="tk">*</a><a id="565c13" class="tk">pBuffer</a> = <a id="565c23" class="tk">&amp;</a><a id="565c24" class="tk">tank_DW</a>.<a id="565c32" class="tk">TransportDelay_RWORK</a>.<a id="565c53" class="tk">TUbufferArea</a>[0];</td></tr>
<tr name="566" id="566">
<td><a id="l566" class='ln'>566</a></td><td>    <a id="566c5" class="tk">tank_DW</a>.<a id="566c13" class="tk">TransportDelay_IWORK</a>.<a id="566c34" class="tk">Tail</a> = 0;</td></tr>
<tr name="567" id="567">
<td><a id="l567" class='ln'>567</a></td><td>    <a id="567c5" class="tk">tank_DW</a>.<a id="567c13" class="tk">TransportDelay_IWORK</a>.<a id="567c34" class="tk">Head</a> = 0;</td></tr>
<tr name="568" id="568">
<td><a id="l568" class='ln'>568</a></td><td>    <a id="568c5" class="tk">tank_DW</a>.<a id="568c13" class="tk">TransportDelay_IWORK</a>.<a id="568c34" class="tk">Last</a> = 0;</td></tr>
<tr name="569" id="569">
<td><a id="l569" class='ln'>569</a></td><td>    <a id="569c5" class="tk">tank_DW</a>.<a id="569c13" class="tk">TransportDelay_IWORK</a>.<a id="569c34" class="tk">CircularBufSize</a> = 1024;</td></tr>
<tr name="570" id="570">
<td><a id="l570" class='ln'>570</a></td><td>    <a id="570c5" class="tk">pBuffer</a>[0] = <a id="570c18" class="tk">tank_P</a>.<a id="570c25" class="tk">TransportDelay_InitOutput</a>;</td></tr>
<tr name="571" id="571">
<td><a id="l571" class='ln'>571</a></td><td>    <a id="571c5" class="tk">pBuffer</a>[1024] = <a id="571c21" class="tk">tank_M</a>-&gt;<a id="571c29" class="tk">Timing</a>.<a id="571c36" class="tk">t</a>[0];</td></tr>
<tr name="572" id="572">
<td><a id="l572" class='ln'>572</a></td><td>    <a id="572c5" class="tk">tank_DW</a>.<a id="572c13" class="tk">TransportDelay_PWORK</a>.<a id="572c34" class="tk">TUbufferPtrs</a>[0] = (<span class="kw">void</span> <a id="572c58" class="tk">*</a>) <a id="572c61" class="tk">&amp;</a><a id="572c62" class="tk">pBuffer</a>[0];</td></tr>
<tr name="573" id="573">
<td><a id="l573" class='ln'>573</a></td><td>    <a id="573c5" class="tk">tank_DW</a>.<a id="573c13" class="tk">TransportDelay_PWORK</a>.<a id="573c34" class="tk">TUbufferPtrs</a>[1] = (<span class="kw">void</span> <a id="573c58" class="tk">*</a>) <a id="573c61" class="tk">&amp;</a><a id="573c62" class="tk">pBuffer</a>[1024];</td></tr>
<tr name="574" id="574">
<td><a id="l574" class='ln'>574</a></td><td>  <span class="br">}</span></td></tr>
<tr name="575" id="575">
<td><a id="l575" class='ln'>575</a></td><td></td></tr>
<tr name="576" id="576">
<td><a id="l576" class='ln'>576</a></td><td>  <span class="ct">/* InitializeConditions for Integrator: '<a class="ct blk" blk_line="576">&lt;S4&gt;/Integrator</a>' */</span></td></tr>
<tr name="577" id="577">
<td><a id="l577" class='ln'>577</a></td><td>  <a id="577c3" class="tk">tank_X</a>.<a id="577c10" class="tk">Integrator_CSTATE</a> = <a id="577c30" class="tk">tank_P</a>.<a id="577c37" class="tk">tank1_initialHt</a> <a id="577c53" class="tk">*</a> <a id="577c55" class="tk">buttomarea</a>;</td></tr>
<tr name="578" id="578">
<td><a id="l578" class='ln'>578</a></td><td></td></tr>
<tr name="579" id="579">
<td><a id="l579" class='ln'>579</a></td><td>  <span class="ct">/* InitializeConditions for Integrator: '<a class="ct blk" blk_line="579">&lt;S3&gt;/Integrator</a>' */</span></td></tr>
<tr name="580" id="580">
<td><a id="l580" class='ln'>580</a></td><td>  <a id="580c3" class="tk">tank_X</a>.<a id="580c10" class="tk">Integrator_CSTATE_i</a> = <a id="580c32" class="tk">tank_P</a>.<a id="580c39" class="tk">Subsystem1_InitialPosition</a>;</td></tr>
<tr name="581" id="581">
<td><a id="l581" class='ln'>581</a></td><td><span class="br">}</span></td></tr>
<tr name="582" id="582">
<td><a id="l582" class='ln'>582</a></td><td></td></tr>
<tr name="583" id="583">
<td><a id="l583" class='ln'>583</a></td><td><span class="ct">/* Model terminate function */</span></td></tr>
<tr name="584" id="584">
<td><a id="l584" class='ln'>584</a></td><td><span class="kw">void</span> <a id="584c6" class="tk">tank_terminate</a>(<span class="kw">void</span>)</td></tr>
<tr name="585" id="585">
<td><a id="l585" class='ln'>585</a></td><td><span class="br">{</span></td></tr>
<tr name="586" id="586">
<td><a id="l586" class='ln'>586</a></td><td>  <span class="ct">/* (no terminate code required) */</span></td></tr>
<tr name="587" id="587">
<td><a id="l587" class='ln'>587</a></td><td><span class="br">}</span></td></tr>
<tr name="588" id="588">
<td><a id="l588" class='ln'>588</a></td><td></td></tr>
<tr name="589" id="589">
<td><a id="l589" class='ln'>589</a></td><td><span class="ct">/*</span></td></tr>
<tr name="590" id="590">
<td><a id="l590" class='ln'>590</a></td><td><span class="ct"> * File trailer for generated code.</span></td></tr>
<tr name="591" id="591">
<td><a id="l591" class='ln'>591</a></td><td><span class="ct"> *</span></td></tr>
<tr name="592" id="592">
<td><a id="l592" class='ln'>592</a></td><td><span class="ct"> * [EOF]</span></td></tr>
<tr name="593" id="593">
<td><a id="l593" class='ln'>593</a></td><td><span class="ct"> */</span></td></tr>
<tr name="594" id="594">
<td><a id="l594" class='ln'>594</a></td><td></td></tr>
</table>
</pre>
</body>
</html>
